sepknow
asked on
Regular Expression - Negate Question
What is the expresion to search for line(s) that does not contain string 20081002 ?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
always look for string functions in C# first. i don't know c# but itshould have IndexOf() or some substring function. Use them, its easierthan spending time creating regexp
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
> I tried with Visual Studio 2005, UltraEdit (Perl, Unix and ultredit option), none work.
Visual Studion *does not support* negative lookahead
perl *does support* it (hence you tests seem to be written wrong)
not sure for ultraedit, but I'd assume that it does not support it
"Unix" is far to vage as it has no "regex" program, if you mean awk, grep, egrep, sed, and many more (inclusing the GNU versions) , the all do not support negative lookahead
Conclusion:
- first you need to know where you want to use your regex
- second, most regex flavious do not support lookarround (lookahead and/or lookbehind),
hence you cannot match "anthing except", but you need to do it programatically or change the tool (to perl for example:)
Visual Studion *does not support* negative lookahead
perl *does support* it (hence you tests seem to be written wrong)
not sure for ultraedit, but I'd assume that it does not support it
"Unix" is far to vage as it has no "regex" program, if you mean awk, grep, egrep, sed, and many more (inclusing the GNU versions) , the all do not support negative lookahead
Conclusion:
- first you need to know where you want to use your regex
- second, most regex flavious do not support lookarround (lookahead and/or lookbehind),
hence you cannot match "anthing except", but you need to do it programatically or change the tool (to perl for example:)
regular expression is not always the solution, in fact it should be the last to come to mind. If the solution can be solved by plain simple string manipulation and comparison, then KISS.
hopefully someone know how to write "KISS" in C#, Java, VB ...
*SCNR*
*SCNR*
How did you try it, and what did not work?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi guys, thanks for the comments.
I asked for regular expression so that I can do search/find/replace easily in UltraEdit or Visual Studio.
If these 2 software cannot support lookaround as what ahoffmann mentioned. Then I shall accept all comments and close this question.
Hi ozo,
Refer to screen shot attached.
The number of match returned was 5388 (using Perl) but actual should be 129.
UltraEdit-Find.bmp
I asked for regular expression so that I can do search/find/replace easily in UltraEdit or Visual Studio.
If these 2 software cannot support lookaround as what ahoffmann mentioned. Then I shall accept all comments and close this question.
Hi ozo,
Refer to screen shot attached.
The number of match returned was 5388 (using Perl) but actual should be 129.
UltraEdit-Find.bmp
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The attached image is a screenshot of what for me in UE with my pattern from 22648827, the checkbox in UE called "List Lines Containing String" is apparently synonymous with the C#.NET RegexOptions.Multiline option.
UltraEdit.bmp
UltraEdit.bmp
Thanks for the question and the points.
ASKER
Hi ddrudik,
yeh, it works. Thanks.
yeh, it works. Thanks.
ASKER
Thanks.
I tried with Visual Studio 2005, UltraEdit (Perl, Unix and ultredit option), none work.