"/href\=(['\"]?)((?<=['\"]{1})[^\\1]*?|(?<=\=|)[^\s>]*)(\\1)/i"

Schrodinger

Golden Member
Nov 4, 2004
1,274
0
0
Originally posted by: Beau
Originally posted by: BingBongWongFooey
I dunno if I would say I like them. They serve a purpose.

A damn good purpose. IMO, they're much more elegant than just about any other string comparison method.

Agreed. They can greatly simplify the validation process. Just make a boolean flag, if the value passed in satisfies the regex then go forward, else throw up error message.

I can't imagine handcoding a bunch of if statements to check the case and characters allowed.
 

Barnaby W. Füi

Elite Member
Aug 14, 2001
12,343
0
0
Originally posted by: Beau
Originally posted by: BingBongWongFooey
I dunno if I would say I like them. They serve a purpose.

A damn good purpose. IMO, they're much more elegant than just about any other string comparison method.

Hah, well I don't know if I could describe "/href\=(['\"]?)((?<=['\"]{1})[^\\1]*?|(?<=\=|)[^\s>]*)(\\1)/i" as "elegant." Regexps can get really nasty. Yeah, they are great in their own way, but they have their ups and downs like anything else. They're not some magical wand.

if $text =~ /^\s*$/

is much less elegant, IMO, than

if not len(text.strip())
 

dighn

Lifer
Aug 12, 2001
22,820
4
81
they are great for string validation and parsing. the readability is horrible though :(