Hello
I'm thinking how should look a regular expression, which match a string, when it doesn't contain two chars when one char directly follows another. For example:
string "ab12c" should NOT be matched, because contain substring "12" ("2" directly follows "1"),
but
string "ab1c2" should be matched, because char "2" doesn't follow "1" directly (there are some trash between, in our example it is char "c").
[^12] doesn't work
[^1(?=2)] doesn't work
... doesn't work ;<
How to do it ?
Many thanks for reply.
Problem with match, when one char follow directly anotother.
Moderator: General Moderators
Re: Problem with match, when one char follow directly anotother.
I know now. If someone want to know that should be:
^(?:(?!12).)+$
^(?:(?!12).)+$
- prometheuzz
- Forum Regular
- Posts: 779
- Joined: Fri Apr 04, 2008 5:51 am
Re: Problem with match, when one char follow directly anotother.
You do as if it was your own, while someone else suggested it to you:jwa wrote:I know now. If someone want to know that should be:
^(?:(?!12).)+$
http://regexadvice.com/forums/thread/45618.aspx
Re: Problem with match, when one char follow directly anotother.
I didn't say that I solved that alone, someone explained me that and I wrote answer here If someone else want to know how to do it.
- prometheuzz
- Forum Regular
- Posts: 779
- Joined: Fri Apr 04, 2008 5:51 am
Re: Problem with match, when one char follow directly anotother.
Good to hear that.jwa wrote:I didn't say that I solved that alone, someone explained me that and I wrote answer here If someone else want to know how to do it.
My point was (or is): give credit where credit is due.
Re: Problem with match, when one char follow directly anotother.
I dont't want to write another thread so that's my second question connected with the flex - fast lexical analyzer.
I'm doing something like that in flex file:
%%
(?:(?!12).)+ { do_something(); }
%%
and the flex print an ERROR: unrecognized rule
I have tested that expression in other utilities and that's 100% correct. So didn't flex recognize that expression.. ?
How match string that will be agree with this regular expression in flex ?
Are there any other possibilities to do that matching in flex?
I'm doing something like that in flex file:
%%
(?:(?!12).)+ { do_something(); }
%%
and the flex print an ERROR: unrecognized rule
I have tested that expression in other utilities and that's 100% correct. So didn't flex recognize that expression.. ?
How match string that will be agree with this regular expression in flex ?
Are there any other possibilities to do that matching in flex?
- prometheuzz
- Forum Regular
- Posts: 779
- Joined: Fri Apr 04, 2008 5:51 am
Re: Problem with match, when one char follow directly anotother.
This is a general regex forum. You'd better ask at the Flex mailing list:
https://lists.sourceforge.net/lists/listinfo/flex-help
Good luck.
https://lists.sourceforge.net/lists/listinfo/flex-help
Good luck.