ErwinM
ErwinM

Reputation: 5131

How to match specific characters in a string only when character is surrounded by space on both sides?

So another regex question:

say i have this string <p> < Hello World > </p>. And I wanted to remove the inner <>, but not the p-tags.

How would I go about making a regex that matches < or > only when they have a space on both sides?

Thanks alot, Erwin

Upvotes: 1

Views: 117

Answers (1)

t56k
t56k

Reputation: 6981

A quick visit to Rubular gives us this answer:

string.match(\s[<>]\s)

Upvotes: 2

Related Questions