EmEditor (text editor) Forum Index Regular Expressions
RegExp OR function misbehaviour ? | Register To Post |
| Threaded | Oldest First | Previous Topic | Next Topic | Bottom |
| Poster | Thread |
|---|---|
| TimGreen | Posted on: 11/10/2009 5:41 am |
Just popping in ![]() ![]() Joined: 11/10/2009 From: Posts: 5 |
Re: RegExp OR function misbehaviour ? By the way: For anyone working with complex RegExes, Regex Buddy is an absolute must. It's worth many times the $30 or so that it costs and comes with the best tutorial for RegEx that I've ever seen. It has fantastic tools to help you build, test and debug RegExes and apply them in most common languages and environments. I use it all the time for building the RegExes that I use in EmEditor and elsewhere and I learn something new every time I use it.
www.regexbuddy.com I don't have anything to do with the company that produces it, I'm just a very happy customer... |
| Salabim | Posted on: 9/13/2009 10:50 pm |
Quite a regular ![]() ![]() Joined: 9/5/2009 From: Ghent (Belgium) Posts: 58 |
Re: RegExp OR function misbehaviour ? It works PERFECTLY thr !
Thank you so much !!!! |
| thr | Posted on: 9/13/2009 9:59 am |
Just popping in ![]() ![]() Joined: 9/12/2009 From: Posts: 3 |
Re: RegExp OR function misbehaviour ? Yes, there were some typos in my posts. Also, I only tested the regular expressions through the Replace dialog. But I just created a macro containing this:
Here at least, it works as expected. |
| Salabim | Posted on: 9/13/2009 9:00 am |
Quite a regular ![]() ![]() Joined: 9/5/2009 From: Ghent (Belgium) Posts: 58 |
Re: RegExp OR function misbehaviour ? Sorry if this all sounds so difficult, the biggest problem is my little knowledge of English to explain the problem
properly, and of course I'm far from a pro into brewing regular expressions. Perhaps, I can give some kind of English example that gives an idea of what I mean. So, In English, correcting the following line(s) properly. Is that possible to properly correct with 1 single line of regexp ? English example : I wantto lookto the car, while doing a salto justto celebrate how great is it. with the example above, you cannot simple say : Look for any word that ends with to and put a space inbetween it, because then the word salto would improperly been turn apart. And of course, checking that the words to search for, are indeed surrounded by a space or a comma, or a newline, is not possible too, because in the English example I gave the space after wantto is being captured, so the regexp doesn't correct the lookto right after it, because there it doesn't see the preceding space because it is handled by the match before it. So, what can I do, I guess I can only write all my regexp's double, or is there any special switch to make it work correctly with 1 line of regexp ? EDIT: before you say look to is not correct and has to be look at, I know ! it'sonly just to give an example. |
| Salabim | Posted on: 9/13/2009 8:01 am |
Quite a regular ![]() ![]() Joined: 9/5/2009 From: Ghent (Belgium) Posts: 58 |
Re: RegExp OR function misbehaviour ? EDIT:
Second line error'ed out, missing ). Even when corrected, doesn't do anything. First line did it completely wrong also, even when I corrected thr's suggestions to have double backslashes, and correct (). It's not the aspect of simplifying things for example to match a whole word followed by [je], I need to use the words in my top post matched, since those MAY NEVER be followed by [je], only when there's a space in between. Other words can be followed directly by je, since I'm correcting Dutch texts, and there je at the end of a word means "little" in English. So, these words translated from Dutch to English. Pak = Box Pakje = Little box Kind = Child Kindje = Little child Hond = Dog Hondje = Little dog ... but Denk = Think Wil = Want Dacht = Thought .... so above cannot be followed by [je] since that is not correct, there doesn't exist any little think, or little want, or little thought. Please, can anyone help me out ? P.S. Sorry for my bad English. |
| Salabim | Posted on: 9/13/2009 5:41 am |
Quite a regular ![]() ![]() Joined: 9/5/2009 From: Ghent (Belgium) Posts: 58 |
Re: RegExp OR function misbehaviour ? Thank you very much for the detailed explanation thr !
I owe you one ! |
| thr | Posted on: 9/12/2009 11:22 pm |
Just popping in ![]() ![]() Joined: 9/12/2009 From: Posts: 3 |
Re: RegExp OR function misbehaviour ? Yes, a positive lookahead only matches, it doesn't "consume" anything. But you can simplify your whole construct like so:
That way you don't need to pay attention to matching the word separators at all. That gives you a lot more leeway. For example, you can then have something like and it will still work as intended, while keeping all word separators intact. Even more simpler with the word shorthand class: |
| Salabim | Posted on: 9/12/2009 3:39 pm |
Quite a regular ![]() ![]() Joined: 9/5/2009 From: Ghent (Belgium) Posts: 58 |
Re: RegExp OR function misbehaviour ? Aaaaagh! Exactly, shame on me that I didn't think about that.
After all, I'm a real newbie regarding regexp's, Only problem, I use bot the first (newline OR space) and the last (newline OR space) in the replacement as \1 and \3 , that means the ?= will NOT assign the following newline or space to \3 ? so with the replacement line of \1\2 je\3 \3 will be empty even if there IS a space or newline after "je", am I right ? Thanks for the help! |
| thr | Posted on: 9/12/2009 10:26 am |
Just popping in ![]() ![]() Joined: 9/12/2009 From: Posts: 3 |
Re: RegExp OR function misbehaviour ? Try this:
|
| Salabim | Posted on: 9/11/2009 11:21 am |
Quite a regular ![]() ![]() Joined: 9/5/2009 From: Ghent (Belgium) Posts: 58 |
Re: RegExp OR function misbehaviour ? Hello Yutaka,
I'm trying to make it as easy as possible, I just want to check for any of these combo's and put a space between them and je, only if these are surrounded by a space or are at the beginning or end of a line. So.... I don't think I can make it simpler than that. |
| (1) 2 » | |
| Threaded | Oldest First | Previous Topic | Next Topic | Top |
| Register To Post | |



