RegEx Pattern (Java) for Finding or Matching Operators

Here is a regular expression pattern that can be used to find the operator in a SQL expression. For that matter any F=V type expression. Given a “field (operator) value” expression, this regex pattern will match and find the operator portion in strings such as…

field = value, field > value, field >=, field <= value, field value, etc..

Pattern: [=\\]*[^a-zA-Z0-9]

Note – The above pattern worked for Java 1.6, and on other languages it maybe possible to remove so of the escape slashes in the “[=\\]” portion to “[=]”.

If you would like to find other RegEx patterns, I recommend GSkinner’s RegExr. Click the “community” tab on the right and you’ll discover a lot of useful patterns:

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s