Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

PHP Regular Expression Help. Delete lines with nothing but spaces.

Posted on 2011-09-02
2
Medium Priority
?
245 Views
Last Modified: 2012-08-13
I'm looking for a regex to delete lines that only have spaces  or tabs on them, and NOT delete all line feeds. So a line with just a  \n or \r would stay, but spaces\tabs and a \n or \r would be deleted
0
Comment
Question by:interclubs
2 Comments
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 36476641
Please post your test data set, thanks.
0
 
LVL 35

Accepted Solution

by:
Terry Woods earned 2000 total points
ID: 36477016
This appears to work:

$data = preg_replace("/^[\t ]+\r?\n/m","",$data);
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses four methods for overlaying images in a container on a web page
This article discusses how to create an extensible mechanism for linked drop downs.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question