0

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?

1 Answer 1

3

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*...";
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.