how can i search lets say FORMULA_TEXT
field in a database where in between start and the end character of '
we have #
or @
for example @A'123'HEY'345''@B'K
SO in this example we have 123
, 345
and @B
in between start and the end of '
character so i want to find these with sql. lets say in each record i have this FORMULA_TEXT
filed and i will check if it contains @
or #
in between start and the and of '
character.
So in my example result is @B
By the way if its too hard I can first find @
s and then #
s which are in between start and end '
character
ps: HEY
is not in between start and the end of ' character in my example.
You can use REGEXP_SUBSTR
:
SQL> SELECT txt, regex, regexp_substr(txt, regex, 1, 1, 'c', '3') result
2 FROM (SELECT q'¤@A'123'HEY'345''@B'K¤' txt,
3 q'¤^([^']*|('[^']*')*?)*?'([^']*[@#][^']*)'¤' regex
4 FROM dual);
TXT REGEX RESULT
-------------------- ---------------------------------------- ---------
@A'123'HEY'345''@B'K ^([^']*|('[^']*')*?)*?'([^']*[@#][^']*)' @B
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.