NameSilo

[Php+regex] Remove new lines

SpaceshipSpaceship
SpaceshipSpaceship
SpaceshipSpaceship
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
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
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
Close
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
Close
DomainEasy: white label portfolios are live. Enable yours.

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Filters for activity feeds
Your news feed, Latest activity, and the activity tab on profiles now have filter buttons: All, Posts, Quick replies, and Other. Your...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back