Solved

perl split

Posted on 2013-01-07
2
390 Views
Last Modified: 2013-01-07
split (/\t+/, $line);  # this code split on tabs (\t), but what does the + after the \t do?
0
Comment
Question by:rgbcof
2 Comments
 
LVL 31

Accepted Solution

by:
farzanj earned 250 total points
Comment Utility
+ means one or more tabs.  So more than one tabs together will also be treated like one tab.
0
 
LVL 84

Assisted Solution

by:ozo
ozo earned 250 total points
Comment Utility
see
perldoc perlre
or
perl -mYAPE::Regex::Explain -e "print YAPE::Regex::Explain->new(qr/\t+/)->explain"
The regular expression:

(?-imsx:\t+)

matches as follows:
 
NODE                     EXPLANATION
----------------------------------------------------------------------
(?-imsx:                 group, but do not capture (case-sensitive)
                         (with ^ and $ matching normally) (with . not
                         matching \n) (matching whitespace and #
                         normally):
----------------------------------------------------------------------
  \t+                      '\t' (tab) (1 or more times (matching the
                           most amount possible))
----------------------------------------------------------------------
)                        end of grouping
----------------------------------------------------------------------
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

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

771 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

10 Experts available now in Live!

Get 1:1 Help Now