anton zamov it expert logo   best php scripts for your website

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




List of Perl pattern match variables

(Perl free example written by Anton Zamov.)


List of Perl pattern match variables

Parentheses not only serve to group elements in a regular expression, they also remember the patterns they match. Every match from a parenthesized element is saved to a special, read-only variable indicated by a number. You can recall and reuse a match by using these variables.

Within a pattern, each parenthesized element saves its match to a numbered variable, in order starting with 1. You can recall these matches within the expression by using 1, 2, and so on.

Outside of the matching pattern, the matched variables are recalled with the usual dollar-sign, i.e., $1, $2, etc. The dollar sign notation should used in the replacement expression of a substitution and anywhere else you might want to use them in your program. For example, to implement "i before e, except after c":

s/([^c])ei/$1ie/g;
The backreferencing variables are:

$+
Returns the last parenthesized pattern match

$&
Returns the entire matched string

$`
Returns everything before the matched string

$'
Returns everything after the matched string

Backreferencing with these variables will slow down your program noticeably for all regular expressions.



Still have questions? Ask your question on TechOnlineHelp.com or find more examples on www.netartmedia.net/examples




If this example was useful for you, please support my company and click Like on the button below. Thank you very much!



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

Pharmacy System, software for running online pharmacies

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-2012