Regex question: independent position of words

you can define a regular expression pattern that validates, for example. for three members independent of their position in the main line?

eg. my string is like"click here to unsubscribe: http://www.url.com"

the template should also work with "http:// unsubscribe click"

THX

+3
source share
3 answers

You can use positive images . For instance,

(?=.*click)(?=.*unsubscribe).*http

- This is a regular expression that will look forward from the current position (without moving forward) for click, then for unsubscribe, then search for in the usual way http.

+9
source

This is possible, but leads to very complex regular expressions, for example:

/(click.*unsubscribe|unsubscribe.*click)/

, . . , .

+2
+2
source

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


All Articles