Solved

perl split

Posted on 2013-01-07
2
396 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
ID: 38753627
+ 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
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

Suggested Solutions

Title # Comments Views Activity
pattern matching in perl 2 111
Can Oracle Client 11.2.0.2.0 work with an Oracle 12c Database? 5 170
perl CPAN issue 3 121
use google analytics code in perl script 2 90
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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…

679 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