Regex tricks: Difference between revisions

From The Jolly Contrarian
Jump to navigation Jump to search
(Created page with "===Tagging evberything coloured blue *search and destroy **double spaces **Fields (ctrl-shift-F9) **bookmarks - there's a cool macro for this: <nowiki>Sub RemoveAllBookmarks(...")
 
No edit summary
Line 1: Line 1:
===Tagging evberything coloured blue
===Tagging evberything coloured blue
*search and destroy
#search and destroy
**double spaces
*double spaces
**Fields (ctrl-shift-F9)
*Fields (ctrl-shift-F9)
**bookmarks - there's a cool macro for this:
*bookmarks - there's a cool macro for this:


<nowiki>Sub RemoveAllBookmarks()
Sub RemoveAllBookmarks()
    Dim objBookmark As bookmark
    Dim objBookmark As bookmark


    For Each objBookmark In ActiveDocument.Bookmarks
    For Each objBookmark In ActiveDocument.Bookmarks
        objBookmark.Delete
    Next
        objBookmark.Delete
End Sub
</nowiki>
    Next
End Sub


clear out all blue dashes - replace them with xxx  
#. Clear out all blue dashes - replace them with xxx  
#. Clear out all blue apostrophes - replace them with yyy
#. Clear ot all blue spaces - replace them with qqq (this won't do the ones either side of the blue phrase)
*Find: ([A-Z][a-z]{1,}) ([A-Z][a-z]{1,}) (use wildcards, font colour: blue)
*Replace: \1qqq/2


clear out all blue apostrophes - replace them with yyy
#. Now your tags are all continuous blue strings. So brace them:
*Find: <([A-Z][a-z]{1,})> (use wildcards, font colour: blue)
*Replace: {{wikitag|\1}} (font colour blue)


Now restore spaces, apostrophes and dashes.


 
Mwah.
clean out all blue spaces between words (this won't do the ones either side of the blue phrase)
 
([A-Z][a-z]{1,}) ([A-Z][a-z]{1,})
to
1\qq\2

Revision as of 17:51, 6 April 2018

===Tagging evberything coloured blue

  1. search and destroy
  • double spaces
  • Fields (ctrl-shift-F9)
  • bookmarks - there's a cool macro for this:
Sub RemoveAllBookmarks()

    Dim objBookmark As bookmark
    For Each objBookmark In ActiveDocument.Bookmarks

        objBookmark.Delete

    Next

End Sub
  1. . Clear out all blue dashes - replace them with xxx
  2. . Clear out all blue apostrophes - replace them with yyy
  3. . Clear ot all blue spaces - replace them with qqq (this won't do the ones either side of the blue phrase)
  • Find: ([A-Z][a-z]{1,}) ([A-Z][a-z]{1,}) (use wildcards, font colour: blue)
  • Replace: \1qqq/2
  1. . Now your tags are all continuous blue strings. So brace them:
  • Find: <([A-Z][a-z]{1,})> (use wildcards, font colour: blue)
  • Replace: Template:Wikitag (font colour blue)

Now restore spaces, apostrophes and dashes.

Mwah.