faqts : Computers : Programming : Languages : PHP : Common Problems : Regular Expressions

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

6 of 9 people (67%) answered Yes
Recently 3 of 5 people (60%) answered Yes

Entry

Where can I use a hyphen (-) inside a [] set in a regular expression?

Aug 12th, 1999 01:59
Nathan Wallace, Adam Trachtenberg


Inside of [] in a regex, if you want a literal "-" it must be at the
beginning or end of the characters; otherwise, it specifies a range of
characters, as in a-z.