Live data from Hacker News

Show HN: Search code in GitHub repos using regular expressions

grep.app

61–70 of 165 posts

Re: Show HN: Search code in GitHub repos using regular expressions

#61

Next post from danfox - “how to get 3 job offers in 3 hours”. Already has been publicly contacted by: - GitHub CTO - SerpApi CEO - SourceGraph CEO Search is hot right now!

If only the answer to "how" was as simple as "writing a web service for searching GitHub repos with regexes," even though the problem is probably in itself non-trivial if there's this much interest in search at all. At least the specification is clear enough.

I guess what I mean to ask is, how would people know this is a "correct" answer to the "how" question beforehand? Is the answer literally just "search" because that's simply what's trending right now?

Re: Show HN: Search code in GitHub repos using regular expressions

#62
post #57

Earlier quoted context omitted.

Actually, It would more be like: "How I failed at 3 interviews, despite being directly contacted by execs."

Sure you built app on multi 20 core machines with functionality to search hundreds of millions of lines of code almost instantaneously, but are you someone I'd drink a beer with?

For some of those companies it would be "drink a La Croix with"

Re: Show HN: Search code in GitHub repos using regular expressions

#64
post #55
post #46

Any plans to include backrefs? I'd like to see how many examples of /(\w+) && \1\./ are out there in .js/.ts compared to /(\w+)\?\./

The about blurb mentions it uses RE2. So backreferences aren't likely. See https://github.com/google/re2/issues/101

Ripgrep is based on RE2 and supports backrefs. Wonder why they didn't use that.

Re: Show HN: Search code in GitHub repos using regular expressions

#65
post #64
post #55

Earlier quoted context omitted.

The about blurb mentions it uses RE2. So backreferences aren't likely. See https://github.com/google/re2/issues/101

Ripgrep is based on RE2 and supports backrefs. Wonder why they didn't use that.

Not quite. ripgrep uses Rust's regex engine, not RE2. Rust's regex engine is descended from RE2, but there is no code sharing.

Rust's regex engine does not support backreferences. RE2 does not either. ripgrep does however have a -P/--pcre2 flag which causes it to use PCRE2 instead of Rust's regex engine. PCRE2 supports backreferences and other things, like look-around. (ripgrep also has an --auto-hybrid-regex flag, which will automatically enable PCRE2 for you if you write a regex with backreferences or look-around.)

The reason not to use an engine like PCRE2 for a project like this is because it would be trivially exposed to ReDoS: https://en.wikipedia.org/wiki/ReDoS

Re: Show HN: Search code in GitHub repos using regular expressions

#66
post #36
post #12

Earlier quoted context omitted.

It was based on the number of stars/forks and the size of the repository.

There must be something else or something wrong, because you indexed one of my small repo (~100 stars, ~20 forks, ~20Mb) and not the bigger ones (~500 stars, ~100/150 forks, ~150Mb)

Maybe he is limiting it to repositories of 50 MB or less, for example.

Re: Show HN: Search code in GitHub repos using regular expressions

#67
post #56

Why regex still exists? It is unintuitive, requires mastering an obscure syntax, it is very hard to debug, and very difficult to explain to others how it works. It feels like we are trying to write intermediate code by ourselves, while we should have a human readable language that generates regex.

"Why regex still exists?" Is there an alternative that is clearly superior?

Your mileage may vary, but to my taste, the lpeg flavor of Parsing Expression Grammars is clearly superior.

It uses operator overloading to build patterns from component parts. I don't think anything can replace the terseness of regex for command line use, or vim searching, cases like that.

But for a program, give me lpeg every time.

Re: Show HN: Search code in GitHub repos using regular expressions

#68

Earlier quoted context omitted.

I'm surprised as well, think why big tech companies didn't have this awesome search already.

If this were to be offered by an actual company (a first party solution), there are some features that'd be expected that make the problem space a lot harder. Here's an "intro to search" article that's a good read, and I'll use it to highlight some of the things that'd be different in a first party solution - https://medium.com/startup-grind/what-every-software-enginee... (See the "Theory: the search problem" section…

Engineering manager for code search at GitHub here... this is an excellent summary of many of the concerns we have as we work on code search at GitHub scale!

Re: Show HN: Search code in GitHub repos using regular expressions

#70

This is awesome! @danfox, sent you an email though commenting here too. I'm the CTO @ GitHub. Would love to talk to you about this and other things we are building in this area at GitHub. Feel free to email direct to jason at github.com

github's code search is notoriously bad, feels like a huge missed opportunity. Nice to see you guys reaching out to other people working in this area.

Good news – they're working on it: https://help.github.com/en/github/searching-for-information-...
Post reply on HN