NameSilo

[Php+regex] Remove new lines

Spaceship Spaceship
Watch

liam_d

The original NP Emo KidEstablished Member
Impact
25
Okay people say i have this:
PHP:
        $pattern = '#\[list\](.*?)\[/list\]#m';
        
        //$replace = ;
        
        $text = preg_replace($pattern, '<ul>$1</ul>', $text);
How would i go about removing any new lines found between the list bbcode tags in the $pattern ?

Is there a way to either remove any new lines directly in that or is there a way to ignore them and grab everything else?
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
.US domains.US domains
something like /[\n\r]/ as the regex for preg_replace to match new lines or even (to avoid regexes which have a high overhead) something like str_replace("\n\r", " ", $oldstring)

Note that (i think) some os's uses \n\r while others use just \n (windows vs mac vs linux)
 
0
•••
something like /[\n\r]/ as the regex for preg_replace to match new lines or even (to avoid regexes which have a high overhead) something like str_replace("\n\r", " ", $oldstring)

Note that (i think) some os's uses \n\r while others use just \n (windows vs mac vs linux)
Win = \r\n
Mac = \r
Linux = \n
 
0
•••
Dynadot — .com Registration $8.99Dynadot — .com Registration $8.99
Appraise.net

We're social

Unstoppable Domains
Domain Recover
DomainEasy — Payment Flexibility
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back