anton zamov it expert logo    

home page latest news web development curriculum vitae scripts contact me


  • Curriculum Vitae (CV)
  • Major web solutions
  • Web design projects
  • Software solutions


  • C# (Microsoft .NET)
  • JAVA
  • Dynamic HTML
  • PHP & MySQL
  • ASP.NET - C# & VB.NET
  • Perl & CGI
  • C | C++
  • Vector Markup Language
  • SMIL
  • Assembler
  • Databases
  • Wap Development
  • Web site promotion
  • Web Marketing




Information for some special symbols in Perl regular expressions.

(Perl free example written by Anton Zamov.)


Information for some special symbols in Perl regular expressions.

=~
This operator appears between the string var you are comparing, and the regular expression you're looking for (note that in selection or substitution a regular expression operates on the string var rather than comparing). Here's a simple example:
$string =~ m/Bill Clinton/; #return true if var $string contains the name of the president
$string =~ tr/Bill Clinton/Al Gore/; #replace the president with the vice president

!~
Just like =~, except negated. With matching, returns true if it DOESN'T match. I can't imagine what it would do in translates, etc.
/
This is the usual delimiter for the text part of a regular expression. If the sought-after text contains slashes, it's sometimes easier to use pipe symbols (|) for delimiters, but this is rare. Here are simple examples:
$string =~ m/Bill Clinton/; #return true if var $string contains the name of the president
$string =~ tr/Bill Clinton/Al Gore/; #replace the president with the vice president

m
The match operator. Coming before the opening delimiter, this is the "match" operator. It means read the string expression on the left of the =~, and see if any part of it matches the expression within the delimiters following the m. Note that if the delimiters are slashes (which is the normal state of affairs), the m is optional and often not included. Whether it's there or not, it's still a match operation. Here are some examples:
$string =~ m/Bill Clinton/; #return true if var $string contains the name of the president
$string =~ /Bill Clinton/; #same result as previous statement

^
This is the "beginning of line" symbol. When used immediately after the starting delimiter, it signifies "at the beginning of the line". For instance:
$string =~ m/^Bill Clinton/; #true only when "Bill Clinton" is the first text in the string

$
This is the "end of line" symbol. When used immediately before the ending delimiter, it signifies "at the end of the line". For instance:
$string =~ m/Bill Clinton$/; #true only when "Bill Clinton" is the last text in the string

i
This is the "case insensitivity" operator when used immediately after the closing delimiter. For instance:
$string =~ m/Bill Clinton/i; #true when $string contains "Bill Clinton" or BilL ClInToN"










Jobs Portal, poweful jobs board software

PHP Mall, multi vendors mall website software

Car Portal, php script for auto classifieds websites

NetArt Media, software products and services

Real Estate Portal, web software for real estate portals

Blog System, multi user blog hosting script

PHP Store, powerful e-commerce system written in PHP


C# (Microsoft .NET) | JAVA | Dynamic HTML | PHP & MySQL | Perl & CGI | C | C++ | Vector Markup Language
SMIL | Assembler | Databases | Wap Development | Web site promotion | Web Marketing

Copyright © Anton Zamov 1998 - 2023