C # RegEx matches start of line and start of word at the same time

Say there are six lines

  • "abcd bbb ccc"
  • "abce bbb ccc"
  • "abcf bbb ccc"

  • "aaa abcd ccc"

  • "aaa abce ccc"
  • "aaa abcf ccc"

User enters expression " <abc[!e]"

This expression is converted to the following regular expression "^ abc [^ e]"

The translated regular expression will successfully match lines 1 and 3

If I need to match lines 4 and 6, the expression should be translated into "\ Wabc [^ e]" (this will also match the space before the characters abc :(, which is not good)

Unfortunately, the expression entered by the user has to be converted to a regular expression that would correspond to integers equal to 1.3 and 4.6.

, "^ abc [^ e]" "\ Wabc [^ e]" ( :))

+3
1

Perl \b:

\babc[^e]

, Perl.

+4

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


All Articles