Link to home
Start Free TrialLog in
Avatar of sepknow
sepknow

asked on

Regular Expression - Negate Question

What is the expresion to search for line(s) that does not contain string 20081002 ?
SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sepknow
sepknow

ASKER

Hi ozo,
Thanks.
I tried with Visual Studio 2005, UltraEdit (Perl, Unix and ultredit option), none work.
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
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
> 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:)
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*
How did you try it, and what did not work?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sepknow

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
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
Thanks for the question and the points.
Avatar of sepknow

ASKER

Hi ddrudik,
yeh, it works. Thanks.