Hacker News new | past | comments | ask | show | jobs | submit login

Out of curiosity, what do you dislike in Python regexes? I switched from Perl to Python years ago and didn't notice much of a difference, other than that you have to write `value = re.sub(pattern, repl, value)` instead of `$value =~ s/pattern/repl/;`.



You have to write a lot more than that. Python's strings don't map well to regex syntax, forcing some odd quoting conventions and/or escapes. Python forces you to instantiate the regex at runtime instead of parse time, so if you want a compiled regex you need a separate bit of code to create it and manage its scope. Perl's captures pop out in automatic variables that can be directly used and interpolated, making simple parsing tasks (e.g. "print "$2 $1\n" if /.../") into sequences of easy-to-read one liners instead of page long "parsers".

All of that is the kind of thing that makes Python people's blood boil, of course, but it's absolutely the reason that regex handling is just so much natural in perl.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: