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



  • Perl with cheese...
    20,087

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

    Matching at the Beginning and End 2



    To match at the end of a string use the dollar sign $:

    $vg="London";

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

    $bh="Visit London Today";

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

    Which Prints:
    vg Matches


    -The dollar sign $ says to match what preceeds it (London) only if at the end of the string.
    -Your variable $vg ends with London so it matches and prints.
    -Your variable $bh doesn't end with London so it does not print.
    -If you removed the dollar sign from the second section, the match would occur because London is in the $bh string, just not at the end.


    Copy and Paste Perl Code:

    #!/usr/bin/perl

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

    $vg="London";

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

    $bh="Visit London Today";

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

    exit;


    Match at the BEGINNING


    Click HERE to comment or discuss at iLoveTheCode GOOGLE Group
    Previous Article: Putting Two Strings Together, Concatenate
    Next Article: Matching at the Beginning and End





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

    Eric Freeman, Elis...

    New $26.39

    DojoDojo

    Matthew A. Russell...

    New $26.39

    Struts 2 in ActionStruts 2 in Action

    Don Brown, Chad Da...

    New $29.69

    jQuery in ActionjQuery in Action

    Bear Bibeault, Yeh...

    New $26.39

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

    Elizabeth Castro

    New $23.09

    Bulletproof Web DesignBulletproof Web Design

    Dan Cederholm

    New $26.39

    CSS MasteryCSS Mastery

    Andy Budd, Simon C...

    New $23.09

    Learning Web DesignLearning Web Design

    Jennifer Niederst ...

    New $29.69


    Of Interest:
  • Use chmod in Perl
  • Opening and Reading a Directory in Perl
  • Matching at the Beginning and End 2
  • OPEN and WRITE a Data File in Perl
  • Use innerHTML to Change Text on a Page
  • Javascript Bold Text
  • Getting Epoch Time in Javascript
  • Increment a Variable in Javascript
  • HTML Title Tag
  • HTML Tags
  • Make a New Paragraph Using HTML
  • HTML Color Chart

  • More Articles:
  • Delete a File Using unlink in Perl
  • Getting What is Matched in Perl
  • To See if a Directory Exists in Perl
  • To Reverse an Array in Perl
  • onClick Javascript
  • Use onClick in Javascript
  • Create a Function in Javascript
  • Getting Epoch Time in Javascript
  • Match with a Regular Expression, REGEX, in Javascript
  • Make Italic Text Using HTML
  • HTML Body Tag
  • Make Strikethrough Text Using HTML
  • HTML Superscript Text

  • 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,827
    Counter by iLoveTheCode.com


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