Kovi
Kovi

Reputation: 138

Ignore some BBCodes in REGEX

I have the following regex and I want to extract the text including [b]. How can I ignore the [b], [i] and [u]

~id="schedule-text".*?]([^[]*)~is

[cs_text id="schedule-text" class="cs-ta-center"]OPEN [b]HOUSE[/b]  Sunday, 12/4 from 2-4pm Additional showings by appointment[/cs_text]

https://regex101.com/r/ukHENx/1

Expected output:

OPEN [b]HOUSE[/b]  Sunday, 12/4 from 2-4pm Additional showings by appointment

Upvotes: 1

Views: 40

Answers (1)

Sahil Gulati
Sahil Gulati

Reputation: 15141

Hope this one will be helpful.

Regex Demo

Regex: id="schedule-text".*?]\K.*?(?=\[/cs)

1. id="schedule-text".*?] this will match id="schedule-text" and till the next occurrence of ]

2. \K this will reset the whole match

3. .*?(?=\[/cs) this will match all and positive look ahead for [/cs

Upvotes: 1

Related Questions