Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Regular Expressions

St. JimmySt. Jimmy Posts: 3
Hey All,

This is more of a regular expressions question than a Java question. I am trying to make a simple SQL statement parser and it seems my regular expression that I use to verify that the select statement is in the form select-from-where isn't working. Here are my example string and regex pattern:

input string: "select A1, B1 from R, S where A4 = rain and A2 = B2;"
regex pattern: "([sS][eE][lL][eE][cC][tT]) [.]+ ([fF][rR][oO][mM]) [.]+ ([wW][hH][eE][rR][eE]) [.]+;"

but it says that the pattern doesn't match the string? :S



  • Okay I got it to work now. What was wrong is that the sections in the pattern where I want to see what the arguments are should not have the [] since those are meant for options that a single character can be. My new pattern is:

    "([sS][eE][lL][eE][cC][tT]) (.)+ ([fF][rR][oO][mM]) (.)+ ([wW][hH][eE][rR][eE]) (.+);";

    Beauty eh?

Sign In or Register to comment.