Perl

Moderators: Jonathan
Number of threads: 1257
Number of posts: 3636

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
what does below code do ?? Posted by abcdef1 on 9 Feb 2011 at 11:54 PM
Hi,

I have below code :

my($abc) = "fred<hello>3hello";
$abc =~ /^[^\d]{2,4}<([^>]+)>\d?\1$/;

if (defined($1)) {
print "$1\n";
} else {
print "not found\n";

}
}

What is the code doing ?? what function of the regular expression

$abc =~ /^[^\d]{2,4}<([^>]+)>\d?\1$/;

??
Report
Re: what does below code do ?? Posted by Trizen on 2 Mar 2011 at 5:56 AM
^ - beginning of the string
[^\d]{2,4} - 2 to 4 characters not containing a digit
([^>]+) - \1 will be one or more characters until '>'
\d? - zero or one digit
\1 - match word '\1' (hello)
$ - final of the string

What is the code doing?
- Matches a string.
Report
This post has been deleted. Posted by Trizen on 2 Mar 2011 at 5:59 AM
This post has been deleted.



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.