Reputation: 6822
How to write a regular expression that excludes a particular prefix string?
Example input: "Hello World - How are you today?"
Desired output: "How are you today?"
Prefix strings to exclude: "Hello world - "
Upvotes: 6
Views: 7999
Reputation: 4078
Sounds to me like you want to replace, so s/^Hello World - (.*)/$1/
. If you just want to match, use (?<=^Hello World - ).*
. Both regexes assume you only want to exclude Hello World -
if it's at the start of a line.
Upvotes: 0
Reputation: 44288
this will match everything after,
(?<=Hello\sWorld\s-\s).*
Upvotes: 4
Reputation: 4259
How about lookbehind? i.e. (?<=Hello World - )How are you today\?
A drawback is in (?<=xxx)
the xxx
must be fixed length (at least in most implementations that I am aware of).
Upvotes: 3