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

Standard Meta Characters

Quantifiers

Quantifiers say how many of the previous substring should match in a row. Here are a few quantifiers:

* + ? {4,8} {5,}

Quantifiers can only be put after atoms, assertions with width.

"AAA000" and "BBBx" equal "[A-Z]+x?[0-9]*"

They attach only to the previous atom, so if you want a quantifier to apply to multiple characters, you must group them together, like this:

/(Bart){3}/ matches "BartBartBart" /Bart{3}/ matches "Barttt"

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