I want <br /><br /> to turn into <br />
What’s the pattern for this with regex?
Note: The <br /> tags can occur more than 2 times in a row.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You could use
s/(<br \/>)+/<br \/>/, but if you are trying to use regex on HTML you are likely doing something wrong.Edit: A slightly more robust pattern you could use if you have mixed breaks:
/(<br\ ?\/?>)+/This will catch
<br/>and<br>as well, which might be useful in certain cases.