I have lines which consist of:
- optional: "no ",
- optional: two non whitespace characters,
- several non whitespace characters.
I want to capture string from each line which consist of:
- optional: two non whitespace characters (but not "no " part),
- several non whitespace characters.
Example lines:
ab123
ab 123
no abc123
no ab 123
I want to capture:
ab123
ab 123
abc123
ab 123
My regexp (works only for examples without "no ").
^
(?! no \s) # not "no "
( # match it
(?: \S{1,2} \s )? # optional: 1-2 non whitespace characters and one space, BUT NOT GET "no " (it doesn't works)
\S+ # non whitespace characters
)
$
Example online (4 unit tests): https://regex101.com/r/70soe2/1
Maybe should I use negative look ahead (?! no \\s) or negative look behind (?<! no \\s) in some way? But I don't know how to use it.