tags:

views:

132

answers:

1

I`m parsing SQL query with C# Regex.

I need also to make my pattern to understand "=", for example:

string pattern = @"...something...(where)\s\w*\s*(order by)*...something else...";

the following query should match my pattern:

select fieldslist from mytable where fieldvalue=someint order by specialfield

how can I change the interval of char (I mean "\w*") to make pattern understand my SELECT correctly?

+3  A: 

Use a character class instead of \w

    \w = [A-Za-z0-9_] 

(that is, from A to Z, from a to z from 0 to 9 plus _)

Just add any additional character you want:

    [A-Za-z0-9_=] 

    string pattern = @"...something...(where)\s[A-Za-z0-9_=]*\s*...";
Vinko Vrsalovic