(I realize many have 'scratchpads' but I wanted something more. Also, by environment, I don't mean a single app).
In particular, I've thought about a website dedicated to string and regex utilities. Whenever I find myself writing a little script to parse a data string, or to toy with a regex, I always think "there must be a better way".
Well, we're one huge step closer: check out the Groovy Web Console, by Guillaume Laforge.
It laughs at basic string utilities:
And provides a test-bed for regular expressions:
def s = "does this string fit into a 32-char column?"
println s.size()
(Note, this is a Java-Groovy hybrid. It's only somewhat 'Groovy'. Making it Groovier is left to the reader)
import java.util.regex.Pattern
def s = "1 - 314-867- 5309"
def p = Pattern.compile(/.*1.*(\d\d\d).*(\d\d\d).*(\d\d\d\d).*/)
def m = p.matcher(s)
if (m.matches()) {
println "area code = ${m[0][1]}"
println "exchange = ${m[0][2]}"
println "digits = ${m[0][3]}"
}
Count me in... I'm definitely going to have this site at hand in my environment.
No comments:
Post a Comment