Perl Special Location

Domain Hosting image
Web Hosting
Dedicated server
ssl certificate
Web Design image
Email

Frequently, you may want to match in a string only if what you're looking for is at the very begining or end of a string. In this case, you should use the carat (A) to indicate the begining of the string and the dollar sign ($) to indicate the end of the string. For example, to check in the string starts with "beg", you would use if ($Test =- /^beg/)

To see if the string ends in "don", you would use if ($Test =- /don$/) ...

The $ character has two wrinkles. If the last character in the string is the newline character, $ forces the search to happen only at the end of the line. Thus, if $Test is either "I Beg Your pardon "or "IBeg Your Pardon\n", searching for don$ will return true. Perl also lets you specify that it should start searching at a world boundary with the \b code. This is the point between a \w and a\w, or between a \w and a \W, or The \b code is useful for finding some text at the begining of a word. For example, to find if a word in the string starts with the letter "Y" you would use

if($Test =~ A bY/) ...
Likewise, to find the letter "J" at the end of a word you would use
if($Test =~ /J\b/). .



Domain Name Search

www.


Copyright (C) 2007. Web Domain design hosting. All rights reserved.