3 ms·
It's worth pointing out that although the Google code search service is going away, RE2, the regular expression engine built for code search by Russ Cox, is ope
by jbarham 15y ago
It's worth pointing out that although the Google code search service is going away, RE2, the regular expression engine built for code search by Russ Cox, is open source (http://code.google.com/p/re2/ http://code.google.com/p/re2/). RE2 is also the basis for Go's regexp package (http://weekly.golang.org/pkg/regexp/ http://weekly.golang.org/pkg/regexp/).
See http://swtch.com/~rsc/regexp/regexp3.html http://swtch.com/~rsc/regexp/regexp3.html for the original writeup from Russ.
- xtacy 15y agoIt wasn't just regex search that I loved Code Search for; it allowed search over functions, classes, etc. It also listed the functions defined in a file in a pane on the left. I wonder if they used a regex for that? It would be nice if they opensource that component as well.
- Resident_Geek 15y ago> I wonder if they used a regex for that? Not possible. You have to parse the file fully to extract that information; regular expressions aren't powerful enough.
- bad_user 15y agoIt depends on what you mean by regex. Modern engines go beyond the capabilities of regular expression grammars, describing things that are not possible with a finite-state machine. And for example, the regex engine from Perl 5.10 and up has had support for recursive patterns. See the faq: http://perldoc.perl.org/perlfaq6.html#Can-I-use-Perl-regular-expressions-to-match-balanced-text%3F http://perldoc.perl.org/perlfaq6.html#Can-I-use-Perl-regular... And once you have recursion support, you can parse context-free languages.
- gujk 15y agoWhat does rsc have to say to jwz about using regexes to match a language?
- deleted 15y ago[deleted]
- mhd 15y agoWhat's the problem using regexps for searching stuff? It's even quite common for lexing, it just gets ugly if try to parse stuff with it (brace matching etc.). (And IIRC, the quote originated from a piece of code where jwz actually did use regexps quite a lot, if just to get enough performance out of elisp)