Regular expression - how to differentiate between > and >=

  • Thread starter Thread starter Peter
  • Start date Start date
P

Peter

Hi,

I could not find a group dealing with just regular expressions. This
groups seems to answer such questions. Hence I am posting it here.

In my grammar, I need to differentiate between GT and GE.

GE is defined as ">="
GT is defined as ">[^=]"

The problem is, GT now picks up things such as x>0. It matches ">0".
In this case, I need it to match only ">"

Can someone please tell me what is the proper syntax?

Thank you in advance for your help.

Peter
 
* Peter wrote, On 2-5-2007 21:18:
Hi,

I could not find a group dealing with just regular expressions. This
groups seems to answer such questions. Hence I am posting it here.

In my grammar, I need to differentiate between GT and GE.

GE is defined as ">="
GT is defined as ">[^=]"

The problem is, GT now picks up things such as x>0. It matches ">0".
In this case, I need it to match only ">"

Can someone please tell me what is the proper syntax?

Thank you in advance for your help.

Peter

You can do this with a negative Look Ahead assertion. It looks at the
next character and makes sure it does not match the expression provided:

[>](?!=)

Jesse Houwing
 
Back
Top