in reply to Regex Learning Tool
For example, many people object to the following in a CGI program:
Why don't I just use HTML with a here document or a template? In this case, the value of the CGI.pm HTML functions is apparent:print $q->Tr( { -bgcolor => $bgcolor[ $toggle->() ] }, $q->td( $key . " " ), $q->td( $q->pre( $data ) );
With your syntax, a person could more naturally write the following:$somevar =~ /^[\d|\w|\*]+$/; # Bad regex, no biscuit.
And you could output /^[\w*]+$/ for the regex (assuming that you check for existence of overlapping metacharacters). This would help with regex syntax problems and could cut down on some of the more insidious logic problems that newbies (and Ovid) are prone to.$match_stuff = form_REx( start, # ^ class("\d\w*"), # [\d|\w|\*] <- still bad! one_or_more, # + end # $ );
Cheers,
Ovid
Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.
|
|---|