Kung Fu Ninja
Kung Fu Ninja

Reputation: 3752

Regex `[quote]`

I have a string as follows:

'[quote]Originally Posted by <strong>first last</strong><br/>zzzzzzzzz[/quote]adaaaaaaaaaaaaaa'

I would like to get the first occurence of [quote] and the last occurence of [/quote] and remove everything in between.

Upvotes: 0

Views: 263

Answers (1)

Gumbo
Gumbo

Reputation: 655219

Without any further knowledge of your regular expression implementation, try the following regular expression and replace the match string by an empty string:

\[quote].*\[/quote]

Since the * quantifier is greedy, it will allow as much repetitions of characters matched by . as possible.

Upvotes: 3

Related Questions