Help plz. create a regexp to search for a substring (that came from the user) that may contain metacharacters. I would not like to preliminarily pass over a substring and screen all metacharacters.
Closed due to the fact that off-topic participants ReinRaus , Nick Volynkin ♦ , Visman , insolor , Peter Olson 26 Aug '15 at 9:03 .
- Most likely, this question does not correspond to the subject of Stack Overflow in Russian, according to the rules described in the certificate .
- The language in which the solution is required is not specified. - ReinRaus
- 3I vote for the closure of this issue as not relevant to the topic, because without specifying PL, one can only guess at which PL should have a solution. Plus, the question load is outdated and there are no qualitative answers to it. - ReinRaus
|
2 answers
It strongly depends on the programming language used, for example in perl / php:
/\Q$substing\E/
- And for Oracle? - wildarg
- Here I pass - you need to read what library Oracle uses, if pcre - then everything is OK, if you have something different - you need to read - chernomyrdin
|
And why exactly regexp? You can try to find the position of the substring in the text. And if it exists, then this substring in the string is.
instr(lower(fieldName), lower(userStr))
Something like that...
|