Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Regex question - line breaks (or not)

Tags:

regex

here's my string:

</HEAD>
<BODY>


<html>
<head>

i need to detect the line-breaks so i used [\r\n]+ but the problem is, i need it to be optional - like the filter rule should also work if there are no line breaks at all (between rbody + html) .. how would i do that?

thx

like image 254
Fuxi Avatar asked Nov 17 '25 07:11

Fuxi


1 Answers

Ivan and qid have it right. [\r\n]* will match any linebreak characters in any amount, including 0. Using + meant 1 or more, thus the problem you ran into.

like image 184
Chris Moschini Avatar answered Nov 18 '25 19:11

Chris Moschini



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!