Mano
Mano

Reputation: 987

Regex to replace <br> and <br/> with \n

I want to replace <br> or <br/> tags with /n(newline).

What is the pattern for this with regex?

Upvotes: 4

Views: 1426

Answers (1)

rkhb
rkhb

Reputation: 14399

Ruby:

a = "I want to replace <br> or <br/> tags with /n(newline)." puts a a.gsub!(%r~<br\s*\/?>~, "\n") puts a

Upvotes: 7

Related Questions