An Introduction to Regular Expressions The Basics 19 of 50 : [PREV] [NEXT]

Standard Meta Characters

Backreferences

\#, where # is an integer, is a backreference to the last substring matching the # parenthetical in the regular expression (counting left parentheses).

in the string "Bart, Lisa, Maggie"
the regular expression /Bart(,)Lisa\1/
matches "Bart, Lisa,"

Note that paired parentheses are numbered by counting left parentheses from the left.


© 2003 Barbie barbie@missbarbell.co.uk Home http://birmingham.pm.org/