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



  • Pass the Javascript, please...
    20,057

    iLoveTheCode.com
    Perl > Perl Tutorials How To Easy > Matching at the Beginning and End

    Matching at the Beginning and End



    To match at the beginning of a string use the carat ^:

    $vg="London";

    if ($vg =~ m/^Lon/) {
    print "vg Matches ";
    }

    $bh="Visit London";

    if ($bh =~ m/^Lon/) {
    print "bh Matches ";
    }

    Which Prints:
    vg Matches


    -The carat ^ says to match what follows (Lon) only if at the beginning of the string.
    -Your variable $vg starts with Lon so it matches and prints.
    -Your variable $bh doesn't start with Lon so it does not print.
    -If you removed the carat from the second section, the match would occur because Lon is in the $bh string, just not at the beginning.


    Copy and Paste Perl Code:

    #!/usr/bin/perl

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

    $vg="London";

    if ($vg =~ m/^Lon/) {
    print "vg Matches ";
    }

    $bh="Visit London";

    if ($bh =~ m/^Lon/) {
    print "bh Matches ";
    }

    exit;


    Match at the END


    Click HERE to comment or discuss at iLoveTheCode GOOGLE Group
    Previous Article: Matching at the Beginning and End 2
    Next Article: What Environmental Variables are Available





    Learning Web DesignLearning Web Design

    Jennifer Niederst ...

    New $29.69

    DojoDojo

    Matthew A. Russell...

    New $26.39

    JavaScriptJavaScript

    David Flanagan

    New $31.49

    Head First HTML with CSS...Head First HTML with CSS & XHTML

    Eric Freeman, Elis...

    New $26.39

    Bulletproof Web DesignBulletproof Web Design

    Dan Cederholm

    New $26.39

    CSSCSS

    Eric Meyer

    New $29.69

    jQuery in ActionjQuery in Action

    Bear Bibeault, Yeh...

    New $26.39

    CSS MasteryCSS Mastery

    Andy Budd, Simon C...

    New $23.09

    Dreamweaver CS3Dreamweaver CS3

    David McFarland

    New $29.69


    Of Interest:
  • Create a Subroutine in Perl
  • What's in an Array, Index Numbers
  • Create or Put Items into an Array in Perl
  • Create an Array of Specific Numbers in Perl
  • Use onMouseOut in Javascript
  • Annoy Users with onBlur in Javascript
  • Javascript Sort - Use Sort on Items in an Array in Javascript
  • Javascript Array - Create an Array in Javascript
  • HTML Superscript Text
  • HTML Tags
  • HTML Forms
  • HTML Center

  • More Articles:
  • What Environmental Variables are Available
  • Encryption with the Crypt Function in Perl
  • To Reverse an Array in Perl
  • Splitting an ARRAY in Perl
  • onClick Javascript
  • Match with a Regular Expression, REGEX, in Javascript
  • Change a Form Field with Javascript
  • Increment a Variable in Javascript
  • If, Else If, and Else in Javascript
  • HTML Tables
  • HTML Codes
  • Make a New Paragraph Using HTML
  • HTML Title Tag

  • 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


    316,797
    Counter by iLoveTheCode.com


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