Regular Expression





Español Français 中文 Deutsch Portuguese Japanese nederlands
   
 
Regex Topics
Introduction Introduction
Common Metacharacter Common Metacharacter's
Metacharacters Metacharacter's
Qualifiers Quantifier's
Word Boundry Word Boundry
Non-word Boundry Non-word Boundry
POSIX Character Classes POSIX-Character Classes
Feedback Feedback
Forums Ask Your Doubts
 




Regular Expression Meta-character Dollar "$"


Tutorials Regular-expression

Topic

What is Regular Expression meta-character Dollar "$"?




Explanation

In Regular Expression, the dollar symbol "$" meta-character is used to find the matching character's from the end of a string.

PHP Example:
    <?php
    $string = "This is a *";
    if (preg_match("/\*$/", $string))
     {
      echo "Pattern found at the end!";
     } 
    else 
     {
      echo "Pattern not found!";
     }
    ?>
Result:
    Pattern found at the end! 

In the above regex example the end of the string is matched for the character "*", and its matched.

Perl Example:
    #! C:\programfiles\perl\bin\perl
    print "content-type: text/html\n\n";
    if ("This is a vessle" =~ m/el$/) 
      {
      print "The regex pattern found at the end.!\n";
      } 
    else 
      {
       print "The regex pattern not found!\n";
      }
Result:
    The pattern not found! 

In the above Regular Expression's example, the string is checked for the pattern "el" at the end of the string "vessel", but its unmatched as the last two characters are "el".





A Note

Simple Regex Regular Expression Tutorial Online. We welcome your Valuable feedbacks or suggestions. This is a copyright content.


Other Links

web hosting