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

x
?
Solved

perl split

Posted on 2013-01-07
2
Medium Priority
?
414 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 1000 total points
ID: 38753627
+ means one or more tabs.  So more than one tabs together will also be treated like one tab.
0
 
LVL 85

Assisted Solution

by:ozo
ozo earned 1000 total points
ID: 38753631
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

Technology Partners: 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

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…
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
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…
Six Sigma Control Plans

971 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