Recovering interrupter with occasional relapses, lover of spreadsheets, blogger, programmer, adept debugger, conjurer of analogies, and probably other things.
For tools, I like to use Ruby to write my regex. I often refer to the documentation. I invariably pair the regex with lots of local tests.
Below is a basic test. I save the code to a file (e.g. regexp.rb) and then run ruby regexp.rb.
THE_REGEX=%r{\d+}defthe_matcher(text)THE_REGEX.match?(text)endif__FILE__==$0[["123",true],["abc",false],].eachdo|text,expected|actual=the_matcher(text)ifactual==expectedputs"SUCCESS: for #the_matcher(#{text.inspect})"elseputs"FAILURE: Expected #the_matcher(#{text.inspect}) to return #{expected}, got #{actual}"endendend
I favor these basic tests as I'm writing regular expressions as they are super fast to run. And are easy to later port into the test suite of the application (which depending on how the application tests are constructed might be faster or slower to run).
For tools, I like to use Ruby to write my regex. I often refer to the documentation. I invariably pair the regex with lots of local tests.
Below is a basic test. I save the code to a file (e.g.
regexp.rb
) and then runruby regexp.rb
.I favor these basic tests as I'm writing regular expressions as they are super fast to run. And are easy to later port into the test suite of the application (which depending on how the application tests are constructed might be faster or slower to run).
For types of problems, I've used it for: