Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #17798
    Stefan
    Participant

    Store and Load your Favorite Find and Replace pattern
     
    So you have composed that fantastic regular expression pattern for the last hour (or two :D ) ?
     
    Now it would be nifty to have a favorite feature with the Find dialog to store e.g. complicated RegEx patterns or often used strings?
     
     
    Right now (Jan. 2014) you can abuse the Batch Replace feature of EmEditor v11
    http://www.emeditor.com/text-editor-features/history/new-in-version-11/#batch_replace
    for this issue, because EmEditor v14 implemented a “go back to Find dialog” button to the Replace: dialog
    http://www.emeditor.com/text-editor-features/history/new-in-version-14/#other-features
    (v14.2 new) The << Find button was added to the Replace dialog box.
     
    …. This is a how-to:
     
    ..

    Store pattern to use later again:
    – open the Find dialog, compose and test your RegEx pattern.
    – click at [Replace >>]
    – click at [Batch >>]
    – click at [Add to Batch], your pattern is now in the list

    ..

    Load a stored pattern:
    – open the Find dialog
    – click at [Replace >>]
    – click at [Batch >>]
    – double click on an stored pattern to add that to the Find: box
    – click at [<< Batch]
    – click at [<< Find]
    – you are now ready to start the find process

    ..

    ..

    Extra Tip:
    You can even Export (store) your collection to a *.TSV file (e.g. RegExPattern.tsv) and exchange it with others and Import (load) it any time later you need it.
    I on my own have even create a sub folder in my EmEditor folder for such files, and named it \BatchReplace to store such TSV files.

     

    HTH?

    #17800
    Stefan
    Participant

    Another tip:

    To add a name or an hint to your stored regex, you can utilize “Named Groups” feature in the .Net framework syntax:
     

    If your regex has many groups, keeping track of their numbers can get cumbersome.
    Make your regexes easier to read by naming your groups
    (?<name>pattern) or (?’name’pattern)
    (pasted from http://www.regular-expressions.info/named.html)

      
     
    We just use that “Named Group” feature to add an comment to our regex pattern,
    we even utilize that “Named Group” feature without adding an regex pattern to it, but just using the comment feature.
      
     
    Example:
     
    (?<Match Two Digits>)\d\d
    or
    (?<Match Two Digits>\d\d)
     
     
    More  Examples
    (?’Match Date’)\d{1,2}-\d{1,2}-\d{4}
    (?<Match IP address>)\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}
     
     
    If you use this feature to add an comment to your stored regular expression pattern,
    you will better memorize later on what this was made for ;-)
     
    HTH?

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.