I have some queries like:
"$Prefex" SELECT column_name(s) FROM table_name WHERE pal pal pal LIMIT "$Suffix"
These queries have unwanted prefixes and suffixes. I used a regex to get rid of the prefix using a non-greedy .*?SELECT
.
I couldn't find a way to use the non-greedy modifier searching backward to eliminate the suffixes.
Ideally, I want a pattern to eliminate from the end of the line to the first match of "LIMIT".
If I use LIMIT.*?
it wan't match anything, while if I use just LIMIT.*
it was greedy, which I want to avoid.
I'm using Ruby for my language.
This is example of the query:
SELECT DISTINCT $val1 $val2 WHERE { $val1 a foaf:val1.$val1 foaf:val2 $val2. FILTER regex($val2 , "CITY LIMITED" , "i")} LIMIT 20&output=xml HTTP/1.1" 200 604 "-" "Python-urllib/2.6" "GB" "65465666654626426246524"
And this is the desired output:
SELECT DISTINCT $val1 $val2 WHERE { $val1 a foaf:val1.$val1 foaf:val2 $val2. FILTER regex($val2 , "CITY LIMITED" , "i")}