Alternatives for regex in Python

Viewed 8426

Regular expressions are highly unreadable and difficult to debug. Does there exist any replacement for text processing which could be handled by mere mortals?

Criteria include

  • It's a library or a tool (please point the answer to the library itself)

  • Human readable syntax (no cheatsheets needed)

  • Documentation with examples

  • Able to debug expressions

If possible can you mention language specific and language independent solutions. I am mainly developing on Python, but I'd hope to see a library which could be ported to other languages/platforms.

I once read that Haskell would have nice text processing capabilities, but again, this is a built-in language solution, not a generic solution.

Edit: Please do not give answers "regular expressions are not bad, do like this!" Stackoverflow.com is not a place for subjective opinions, but I think a regular expressions are bad and I want to see my alternative options for using them.

6 Answers

If you're concerned about understanding and debugging others' regex, there are translational tools that make them more easily understandable. My favorite is RegExBuddy on Windows. On Mac, RegExRx in the AppStore is helpful.

Related