Is their any wizards or tools to create and test regular expressions for PHP, because it is so difficult :( ? thanks :)
20 Answers
RegexBuddy is a widely popular app for this purpose. It also costs $40 and only runs on Windows.
For powerful free alternatives, see this answer.
1 Comment
reAnimator is a nice tool to visualize your regex as a state machine- I find it useful sometimes.
Python also allows you to view a regex parse tree, which can be helpful if you learn to read it.
Comments
Unit testing with example data. Create two arrays, one with matching data, and one with non-matching data if necessary to test edge cases.
1 Comment
Trial and error success.
Because I've spent the time to actually learn it, instead of relying on something else to do it for me.
Same applies to any language/tool - take a bit of time to learn the syntax and general ethos, and you'll be far more productive than relying on intellisense, code hinting, and so on.
2 Comments
There are powerful online tools. Offline,
- The Regex Coach is a great free offline regex tool that I use fairly regularly.
- I like RegEx Buddy also, but it costs $40 and I'm cheap.
Comments
Expresso is free Windows program and gives nice breakup and explanation of the regex under analysis.
For online tools that you can run right away from a browser, see this answer.
Comments
1 Comment
Trial and error.
And print_r.
1 Comment
Online... there's an ajax regex checker with js/pcre/posix implementations, that checks as you type.. way cool.
Comments
Regex Buddy is overkill ($40) and works only on Windows. It was a good choice back in 2009 maybe.
Now we have free powerful online tools to build and test regular expressions. Regex101 is one of them:
- lets you select the RE engine (PCRE, JavaScript, Python)
- colorizes the matches
- explains the regexp on the fly
- has a debugger
- can create permalinks to the regexp playground.
More regexp testing tools in my other answer.
Comments
I generally use Rubular when I'm working on testing a regular expression. You could also try txt2re.com, it can be handy for helping you figure out an expression and can even generate relevant PHP code.
Comments
I used to use The Regex Coach. But because it's Perl based and most of the time I'm testing .NET regular expressions, I now use this online .NET regular expression tester.
Comments
I've written my own tool: Regular Expression Tester. Unlike many other web-based tools, this one can break a regex down into tokens and describe what each token is doing. It's great for examining new expressions, or expressions that you wrote a long time ago and don't quite remember.
Comments
Since you're talking about PHP, you may be interested in Codebench. It is a tool, not specifically to break down regexes (you've got a lot of those listed already), but to benchmark them. Since it is rather generic, you can also compare non-regex solutions as often native string functions are faster. Moreover, it allows you to benchmark against multiple subjects (targets) as well. Hope you find it useful.
Comments
Here is another online regular expression tester for Java:
Comments
For online test Regx http://www.regexr.com/ use this site and if your regx work on this then you can check it for php on writecodeonline.com with preg_match() function.
Comments
I wrote a python library to accomplish this, it is under cloudtb.re
text = 'so foo is the opposite of bar but without foo there is no bar?' exp = '(foo).*?(bar)' searched = cre.research(exp, text) print(searched) 