EmEditor (text editor) Forum Index
   Regular Expressions
     Example please for (?n:true_expression:false_expression)
Register To Post

Flat Previous Topic | Next Topic
Poster Thread
JohnQSmith
Posted on: 10/18/2011 10:39 am
Not too shy to talk
Joined: 7/15/2011
From:
Posts: 30
Re: Example please for (?n:true_expression:false_expression)
Quote:
My understanding right now:
You have to set up the FIND RegEx with an alternation so that it has both a success and a failure point.
As the REPLACE have too possibilities too: (?n:true_expression:false_expression)

Absolutely correct. I like your FIND RegEx better. It will be much easier to use than mine. Just adding the zero or more switch makes it much simpler than a non-matching alternation grouping.

What helped me the most in figuring out how it works was how EmEditor highlights all matches when you do a search. When I tried your first search, only the first "Test Price" line was highlighted, but when I removed the final "(\d)", all the lines were marked. This showed me that the problem was with the RegEx.

The first and foremost thing to remember is that the WHOLE RegEx expression must match before you can do any further matching and testing with a SUBexpression.

Quote:
BTW, good idea of you:
Replace: \0 (?4:too expensive:affordable)

Thanks!
Flat Previous Topic | Next Topic


Subject Poster Date
   Example please for (?n:true_expression:false_expression) Stefan 10/13/2011 10:51 pm
     Re: Example please for (?n:true_expression:false_expression) JohnQSmith 10/17/2011 12:10 pm
       Re: Example please for (?n:true_expression:false_expression) Stefan 10/17/2011 9:46 pm
         Re: Example please for (?n:true_expression:false_expression) Stefan 10/17/2011 11:18 pm
           Re: Example please for (?n:true_expression:false_expression) JohnQSmith 10/18/2011 6:39 am
             Re: Example please for (?n:true_expression:false_expression) Stefan 10/18/2011 10:12 am
             » Re: Example please for (?n:true_expression:false_expression) JohnQSmith 10/18/2011 10:39 am

Register To Post
 
English čeština Deutsch español français italiano 日本語 한국어 Русский 简体中文 繁體中文