Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2011-09-02
2
Medium Priority
?
239 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

721 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