NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page [php+regex] remove new lines

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search
5 members in live chat ~  


Reply
 
LinkBack Thread Tools
Old 08-24-2010, 10:22 AM THREAD STARTER               #1 (permalink)
The original NP Emo Kid
 
liam_d's Avatar
Join Date: Jan 2005
Location: Plymouth, UK
Posts: 1,693
liam_d is a name known to allliam_d is a name known to allliam_d is a name known to allliam_d is a name known to allliam_d is a name known to allliam_d is a name known to all
 




[php+regex] remove new lines


Okay people say i have this:
PHP Code:
        $pattern '#\[list\](.*?)\[/list\]#m';
        
????: NamePros.com http://www.namepros.com/programming/673797-php-regex-remove-new-lines.html
        
//$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?
liam_d is offline   Reply With Quote
Old 08-24-2010, 11:34 AM   #2 (permalink)
Senior Member
 
nasaboy007's Avatar
Join Date: Jul 2005
Location: NJ
Posts: 1,219
nasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud of
 



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)
nasaboy007 is offline   Reply With Quote
Old 08-24-2010, 01:59 PM   #3 (permalink)
Tech Support
Join Date: Mar 2005
Posts: 4,944
Eric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatness
 

Member of the Month
MOTM September 2005
Save a Life Child Abuse 9/11/01 :: Never Forget Baby Health Marrow Donor Program AIDS/HIV Breast Cancer Animal Rescue Cystic Fibrosis Ethan Allen Fund Animal Cruelty Ethan Allen Fund Ethan Allen Fund Baby Health Cancer Alzheimer's Protect Our Planet Cancer Survivorship SIDS Child Abuse Diabetes Protect Our Planet Multiple Sclerosis Autism Adoption Special Olympics
Originally Posted by nasaboy007 View Post
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)
????: NamePros.com http://www.namepros.com/showthread.php?t=673797

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
Eric is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


 
All times are GMT -7. The time now is 02:37 PM.

Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger