I have the string below:
"g1_fim[7,8] || '/' || g1_fim[5,6] || '/' || g1_fim[1,4] dt_final, campo1, campo2 WHERE **d1_fim || d2_teste** = 'sadasd'"
I´d like an regular expression to match X||X (text before and after double pipes)
The result should be something similar to these two matches:
1. g1_fim[7,8]||'/'||g1_fim[5,6]||'/'||g1_fim[1,4]
2. d1_fim||d2_teste
I´ve tried to use this expression .*?(\|\|).*?(?=\s)
Bute the results are:
1. g1_fim[7,8]||'/'||g1_fim[5,6]||'/'||g1_fim[1,4] ( its ok !!! )
2. dt_final, campo1, campo2 WHERE d1_fim||d2_teste (it´s not ok, I´d like to return here only the 'd1_fim||d2_teste' )
Would this work for you:
\S+(?:\s*\|\|\s*\S+)+