1

I want to negate the string

*.INFO

How can I do this?

I have tried

^(?!.*\*\.INFO).*$

but it is not working.

VladL
  • 12,769
  • 10
  • 63
  • 83
user2114865
  • 15
  • 1
  • 1
  • 4
  • Can you elaborate on "not working?" What language is this in, and can you give a few test strings and some sample code that you've tried it in? It seems to work fine if you plug it in here: http://regexpal.com/ – jonvuri Mar 06 '13 at 11:57
  • Define "negate". Do you mean anything other than exactly `*.INFO`, or anything not *containing* `*.INFO`? – Bohemian Mar 06 '13 at 12:02
  • I am writing this rule in a lex file. The test file look like: * \n *.ABCD \n *.MNC a=10 \n *.INFO A B C D \n start. Now i just want to ignore the strings which starts from *. except *.INFO. So i need to define a rule which identify all strings starting from *. except *.INFO. @Bohemian So i mean anything starting from *. other than exactly *.INFO . – user2114865 Mar 07 '13 at 04:52

2 Answers2

0

You are nearly correct

^(?![*][.]INFO).*$

you can test it here

VladL
  • 12,769
  • 10
  • 63
  • 83
0

Based on your recent comment, this matches anything starting with *. except *.INFO:

\*\.(?!INFO\b)\S+

Note that by adding the \b to INFO this will match strings that start with*.INFO but are followed by other characters, eg *.INFOXYZ

Bohemian
  • 412,405
  • 93
  • 575
  • 722