RegEx to match string markers in any order?

I am looking for an Oracle Regular Expression that will match tokens in any order.

For example, let's say I'm looking for "one two."

I would like it to match both, “one sign two” “two others”

The number of tokens can increase by more than two, so the generation of permutations for the regular expression will be hassel.

Is there an easier way to do this than this

'(ONE.*TWO)|(TWO.*ONE)'

 i.e

select * 
from some_table t
where regexp_like(t.NAME_KEY, '(ONE.*TWO)|(TWO.*ONE)')
+3
source share
2 answers

Here's an alternative query that uses full-text search (FTS):

WHERE CONTAINS(t.name_key, 'ONE & TWO') > 0

See Examples of Priorities for a description of the evaluation criteria .

on this topic:

+6

:

SELECT * 
FROM some_table t
WHERE regexp_like(t.NAME_KEY, 'ONE')
AND regexp_like(t.NAME_KEY, 'TWO')

, "TWONE", . , .

, . LIKE.

+1

Source: https://habr.com/ru/post/1762496/


All Articles