I want to extract the content after the :
, but there can be only one :
.
Examples:
foo:bar # match, extract 'bar'
foo:123 # match, extract '123'
foo:bar:123 # do not match
So that last example should not match because it has multiple :
.
I tried a negative lookbehind ^. (?<!:):(. )$
but that nonetheless matches and extracts from that last example.
Here's a demo.
CodePudding user response:
Try (regex101):
^[^:] :([^:] )$
This will match only lines with one :
and get the string after the :