Showing posts with label regex. Show all posts
Showing posts with label regex. Show all posts
Saturday, October 3, 2015
The best regexp trick ever
It's true. It is! It's just this. Say I want to find all instances of X that aren't in quotes. Then I just say /"X"|(X)/ and ignore overall matches, just taking group 1 matches. Pretty brilliant, actually!
Monday, August 5, 2013
Express regexes with verbal expressions
Neat JS library for expression of simple regex use cases in non-incomprehensible form. This is an interesting start, but I don't see any way to extend it to more complicated use cases (identified match outputs, replacements, alternates with any nested structure, and so on).
Although for a lot of things, honestly, regexes should be replaced by explicit grammars with named components and a match specification.
Anyway, this is a nice start and deserves contemplation.
Although for a lot of things, honestly, regexes should be replaced by explicit grammars with named components and a match specification.
Anyway, this is a nice start and deserves contemplation.
Friday, July 19, 2013
Regex crossword and constraint programming
So there's this neat little Regex learning site at Regex Crossword - it's fun. I worked straight through it and enjoyed the whole thing. (HNN quote that made me laugh: "I tried to solve these with regular expressions. Now I have two crosswords.").
This led to the realization that constraint programming is actually a fun type of puzzle - and that automating it is something that was once considered AI, but is now no-true-Scotsmanned out of the domain. One example of a solution to this kind of problem using Haskell's Regex.Genex package is here. Cool stuff!
This led to the realization that constraint programming is actually a fun type of puzzle - and that automating it is something that was once considered AI, but is now no-true-Scotsmanned out of the domain. One example of a solution to this kind of problem using Haskell's Regex.Genex package is here. Cool stuff!
Wednesday, May 29, 2013
Regex power
Here is a fantastic article about regular expressions, not as they are defined mathematically, but as implemented in real languages - with backreferences, regexes become NP-complete... Which blows my mind. I had no idea!
They're still unreadable, of course. Which means it might be worthwhile (1) to work through (or write) a really good tutorial set and (2) write some kind of ... regex preprocessing parser thing. Which probably already exists, of course.
Anyway, that article led me to the existence of Thue, a string-rewriting language that looks ... weird, to say the least. Note that Thue is definitively described on a Wiki devoted to esoteric programming languages.
They're still unreadable, of course. Which means it might be worthwhile (1) to work through (or write) a really good tutorial set and (2) write some kind of ... regex preprocessing parser thing. Which probably already exists, of course.
Anyway, that article led me to the existence of Thue, a string-rewriting language that looks ... weird, to say the least. Note that Thue is definitively described on a Wiki devoted to esoteric programming languages.
Subscribe to:
Posts (Atom)