CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Regular Expressions: Re: [masaniparesh] Need help in tab separator string: Edit Log


Jul 29, 2009, 10:19 AM

Views: 19865
Re: [masaniparesh] Need help in tab separator string

Maybe this will do what you need:"

@array = ("test with one tab no space\ttest","test with one tab and space   \ttest", "test with two tabs\t\ttest");    
for (@array) {
if (/^([^\t]+)(?<! )\t([^\t]+)$/) {
print "$1 $2\n";
else {
print "Did not match\n";

?<! is a zero-width negative look behind assertion. Zero-width assertions don't capture and store patterns in memory so $2 is not affected, in other words you don't have to use $3 to capture and store what is inside the third set of parentheses.

Some reading:

(This post was edited by KevinR on Jul 29, 2009, 10:20 AM)

Edit Log:
Post edited by KevinR (Veteran) on Jul 29, 2009, 10:20 AM

Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives