Reputation: 13357
I have a regex pattern per the following example.
Essentially it just matches the first instance of the specific regex pattern.
However, as a one off derivation I can get the following to match if there is just one pattern (matches first instance with blank line & a space above the pattern).
However, if the pattern is on the very first line then there is no match.
How can I get that last example to match on the first line?
Upvotes: 1
Views: 84
Reputation: 41838
^(.+?)?\byo\b(?:(?!cut me:|yo).)*cut me:
I just added a ?
after the (.+?)
to make it optional.
Upvotes: 1
Reputation: 124225
How can I get that last example to match on the first line?
Regex: ^(.+?)\byo\b(?:(?!cut me:|yo).)*cut me:
requires one or more characters before by
because of +
in (.+?)
. Consider changing it to (.*?)
.
Upvotes: 3