Solved

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

Posted on 2011-09-02
2
215 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 108

Expert Comment

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

Accepted Solution

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

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

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Whatever be the reason, if you are working on web development side,  you will need day-today validation codes like email validation, date validation , IP address validation, phone validation on any of the edit page or say at the time of registration…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

762 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now