Regular expression - how to differentiate between > and >=

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
 
J

Jesse Houwing

* 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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top