Yes, some of this is shell dependant. I prefer using [x] over \x for escaping characters in regular expressions -- I just think it is easier to read (though it might make the regex slightly slower if the regex compiler doesn't optimize single-char classes -- I hadn't really worried about that before). It is unfortunate that the convoluted rules for detecting variable names inside regexes think [$] is trying to expand the variable $] so you can't use this trick to escape a dollar sign in a regexp.
In most Unix shells, you can switch between quoting styles to make your life easier:
perl -pi.orig -e 's#<% $flat->purge'"[(]'dynamix','outburst'[)] %>#"'$ +CONFIG{DYNAMIX_OUTBURST}#ge' www/index.html
Under Win32, you'd use:
- tye (but my friends call me "Tye")perl -pi.orig -e "s#<% $flat->purge[(]'dynamix','outburst'[)] %>#$CONF +IG{DYNAMIX_OUTBURST}#ge" www/index.html
In reply to Re: Regex Help
by tye
in thread Regex Help
by meonkeys
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |