I have following Python regex:
re =re.match(r'.*? from\s+(.*?)(\s.*|$)', q)
Here, q is a query like this:
Q1 = u"select * from dlpx_jobs where job_id=\\'531\\';"
Q2 = u"select * FROM dlpx_jobs where job_id=\\'531\\';"
Now, obviously, for Q1 the regex works because "from" is lowercase in the query but for Q2 regex doesn't work because in Q2 "from" is in Uppercase.
Is there any way through which the regex works for both the query irrespective of whether "from" is uppercase or lowercase?
Try this:
expr = re.match(r'.? from\s+(.?)(\s.*|$)', q, re.IGNORECASE)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With