iLTC Home
Bookmark iLTC!
iLTC Google Boards

Google Groups
Receive The Code in Email!



Categories

Perl
  • Perl Tutorials Beginners

    Javascript
  • Javascript Tutorials
  • Javascript Tutorials Beginners

    HTML
  • HTML Tutorials



  • I love the code... dot com
    143,007

    iLoveTheCode.com
    Perl > Perl Tutorials How To Easy > Getting What is Matched in Perl

    Getting What is Matched in Perl



    To get what is matched:

    $ji="London";

    if ($ji =~ m/(Lon)/) {
    print "$1";
    }

    Which Prints:
    Lon


    -We created a variable named $ji and stored London there.
    -We put parenthesis around what we wanted to match Lon
    -The parenthesis are stored in the built-in variable $1


    if ($ji =~ m/(Lon(don))/) {
    print "$1 $2";
    }

    Which Prints:
    London don

    -Whatever matches the first set of parenthesis is stored in $1
    -The second set is stored in $2 and so on...




    Copy and Paste Perl Code:

    #!/usr/bin/perl

    print "Content-type:text/html\n\n";

    $ji="London";

    if ($ji =~ m/(Lon(don))/) {
    print "$1 $2";
    }

    exit;


    Resources:
    Matching with a Regular Expression, REGEX, in Perl


    Click HERE to comment or discuss at iLoveTheCode GOOGLE Group
    Previous Article: Passing a Variable or Value to a Subroutine in Perl
    Next Article: Check for Existing File in Perl





    Bulletproof Web DesignBulletproof Web Design

    Dan Cederholm

    New $23.99

    HTML & XHTMLHTML & XHTML

    Chuck Musciano, Bi...

    New $29.99

    New Perspectives on HTML...New Perspectives on HTML, XHTML, and...

    Patrick Carey

    New $69.26

    jQuery in ActionjQuery in Action

    Bear Bibeault, Yeh...

    New $26.39

    JavaScriptJavaScript

    David Flanagan

    New $31.49

    CSSCSS

    Eric Meyer

    New $29.69

    Information Architecture...Information Architecture for the Wor...

    Louis Rosenfeld, P...

    New $26.39

    HTML, XHTML, and CSS, Si...HTML, XHTML, and CSS, Sixth Edition ...

    Elizabeth Castro

    New $23.09


    Of Interest:
  • Matching at the Beginning and End
  • Opening and Reading a Directory in Perl
  • Delete a File Using unlink in Perl
  • INCREMENT and DECREMENT a Variable in Perl
  • Javascript Slice - Use Slice to Get Items from an Array in Javascript
  • Javascript Join - Use Join to Make an Array into a String in Javascript
  • Exit a For Loop in Javascript with Break
  • Javascript Splice - Use Splice to Replace Items in an Array in Javascript
  • HTML Codes
  • HTML Subscript Text
  • HTML Body Tag
  • HTML Tables

  • More Articles:
  • Add to End of an Array with Push in Perl
  • What's in an Array, Index Numbers
  • Matching at the Beginning and End 2
  • Write a FOR LOOP in Perl
  • onClick Javascript
  • Getting Epoch Time in Javascript
  • Use onMouseOut in Javascript
  • Formatting Time in Javascript
  • Mimic Typing from a Textfield in a Textarea with Javascript
  • HTML Tags
  • Make Italic Text Using HTML
  • Make a New Paragraph Using HTML
  • Make a Line Return Using HTML

  • Search iLTC w/ Google





    Recent Articles

  • Javascript Focus Form Field
  • Javascript Lowercase Text
  • Javascript Uppercase Text
  • Javascript Superscript Text
  • Javascript Subscript Text
  • Make Text Blink Using Javascript
  • Make a String into a Link in Javascript
  • Javascript Italics Text
  • Javascript Bold Text
  • Javascript Redirect
  • HTML Frames
  • HTML Color Chart
  • HTML Link
  • Javascript Status Bar








  • Perl Programming - Javascript Programming - Maybe Some PHP - Free Scripts - ILoveTheCode
    All Content © 2006 iLoveTheCode.com


    Contact Chris | About this Site


    439,772
    Counter by iLoveTheCode.com


    Last Modified: Friday, 23-Jun-2006 07:23:13 EDT