ptrcao
ptrcao

Reputation: 423

Implementing a string exclusion in regex

What regex rule would drop the preceding "> " (greater than symbol followed by a space).

> Bay of Pigs

translates to

Bay of Pigs

I have tried:

[^>\s]

which has not worked

Upvotes: 1

Views: 52

Answers (1)

Sufiyan Ghori
Sufiyan Ghori

Reputation: 18753

You can use positive look-behind,

(?<=>\s).*

Positive Look-behind

(?<=...) Ensures that the given pattern will match, ending at the current position in the expression. The pattern must have a fixed width. Does not consume any characters.

Concisely, it matches anything after > and a space character \s

Click here for demo

Upvotes: 1

Related Questions