Find the answer to your Linux question:
Results 1 to 2 of 2
Hi, I have below code in perl : Code: my($abc) = "fred<hello>3hello"; $abc =~ /^[^\d]{2,4}<([^>]+)>\d?
$/; if (defined($1)) { print "$1\n"; } else { print "not found\n"; } } What is ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Feb 2011
    Posts
    1

    what does below code do ??


    Hi,

    I have below code in perl :
    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$/;

    ??

  2. #2
    Linux Guru Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,252
    This sounds like a homework question. Homework questions are not allowed as per the forum rules:

    http://www.linuxforums.org/forum/lin...ums-rules.html

    You can look this up for yourself by Googling for information on regular expressions in general, and Perl regular expressions in particular.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •