Hacker GitHub

← All repos

google/re2

View on GitHub ↗ ★ 9,842 C++

RE2 is a fast, safe, thread-friendly alternative to backtracking regular expression engines like those used in PCRE, Perl, and Python. It is a C++ library.

51 mentions on Hacker News by 41 people: 7 stories, 44 comments · first 2015-06-04 · latest 2024-09-05

Mentions per year 51 mentions · busiest year 2019 (9)
20082026
  1. …) which parses the regex and instantiates the automaton entirely at compile-time, or Google's re2 ( https://github.com/google/re2 ) if you need to generate regular expressions at run-time. Even boost.regex on which std::regex is originally…
    comment by jcelerier · 2024-09-05 · in Giving C++ std:regex a C makeover
  2. ▲ 70
    RE2 maintainer Paul Wankadia died
    story by danlark · 2024-07-08 · 11 comments
  3. RE2 may beg to differ, if you care about performance. https://github.com/google/re2 Agreed on Larry Wall understanding the difference between linguistics and computer science, languages for humans to use vs languages for computers to use.
    comment by lupire · 2024-07-06 · in What Happened to Perl 7? (2022)
  4. …guess if they used Google's re2 Regex library instead of Boost's, the result would be different. https://github.com/google/re2 https://github.com/greensoftwarelab/Energy-Languages/blob/ma...
    comment by felixguendling · 2024-01-26 · in C Is the Greenest Programming Language
  5. Use re2 instead. It's nearly a drop-in replacement: https://github.com/google/re2 There are python bindings: https://pypi.org/project/google-re2/ I just had to point out a similar problem in a Swift project. I'd like to submit a PR to…
  6. …But with there are non-backtracking matchers which would make this O(n). Here's re2 from https://github.com/google/re2 : >>> import re2 >>> opts = re2.Options() >>> opts.max_mem = 200000000 >>> matcher = re2.compile(pattern, opts) >>>…
    comment by eesmith · 2023-04-12 · in On a great interview question
  7. …"caching" approach documented in the Ruby bug ticket linked for quite some time (since its birth?): https://github.com/google/re2/blob/954656f47fe8fb505d4818da1... It is mentioned only briefly in Cox's article on regex matching in the…
    comment by burntsushi · 2023-01-04 · in Ruby 3.2.0 is from another dimension
  8. …. (The second closest I've found in another repo is in RE2 from Mar 2010, https://github.com/google/re2/blame/954656f47fe8fb505d4818da... - and yes, both of these existed prior to the listed date, but I'm going off associated timest
    comment by joatmon-snoo · 2022-12-14 · in Golink: A private shortlink service for tailnets
  9. See also: https://github.com/google/re2/blob/main/re2/bitstate.cc Although its space complexity is P*T, which limits its use to small regexes/haystacks. It sounds like your claim is that your technique achieves a smaller space bound?
    comment by burntsushi · 2022-08-12 · in Rob Pike's simple C regex matcher in Go
  10. …if you use lookaheads, etc. The design philosophy behind RE2 for those unfamiliar with the library: https://github.com/google/re2/wiki/WhyRE2
  11. …know, that would completely eliminate the possibility of catastrophic backtracking happening. [1]: https://github.com/google/re2
  12. …strings that can be matched in a single pass through the text using only a fixed amount of memory. https://github.com/google/re2/wiki/Syntax Note that RE2 doesn't support backreferences.
  13. ▲ 48
    RE2: iOS got rejected due to legal issue (Guideline 5.0 – Legal) Syria
    story by lifthrasiir · 2022-02-10 · 8 comments
  14. …performance comparisons to glibc, rust regex and cl-ppcre, but re2 was missing from that list. [1] https://github.com/google/re2
  15. …intersection and complement though.[3] [1] - https://dl.acm.org/doi/10.1145/2071368.2071372 [2] - https://github.com/google/re2/issues/156#issuecomment-354068... [3] - https://github.com/google/redgrep
    comment by burntsushi · 2021-01-01 · in State machines are wonderful tools
  16. ▲ 1
    RE2: A fast, thread-safe alternative to backtracking regular expression engines
    story by ogogmad · 2020-09-02 · 0 comments
  17. …tool are based upon the knowledge found in Russ Cox's articles. Also, the link above on RE2: https://github.com/google/re2 is a project that was was also (started by|heavily contributed to by) Russ Cox. His writings on the topic of regular…
  18. …https://github.com/oilshell/blog-code/tree/master/regular-la... [1] https://github.com/google/re2 ---- Also, the production quality way of compiling regular expressions to C code looks like this [2], which is completely differ
  19. Active repository, https://github.com/google/re2
  20. …https://swtch.com/~rsc/regexp/regexp2.html And actual implementations based on these articles: https://github.com/google/re2 and https://github.com/rust-lang/regex
  21. …about this a bit in part 3 of his articles on regex matching[1]. Its implementation in RE2 is here: https://github.com/google/re2/blob/master/re2/dfa.cc [1] - https://swtch.com/~rsc/regexp/regexp3.html
    comment by burntsushi · 2020-03-15 · in The most surprising Unix programs
  22. The about blurb mentions it uses RE2. So backreferences aren't likely. See https://github.com/google/re2/issues/101
  23. …the Elisp reference manual: https://www.gnu.org/software/emacs/manual/html_node/elisp/Sy... . [1] https://github.com/google/re2/wiki/Syntax
    comment by alexhutcheson · 2020-01-31 · in Show HN: Regex Cheatsheet
  24. ▲ 1
    RE2 regular expression syntax reference
    story by shawndumas · 2019-08-05 · 0 comments
  25. …But real progress would be removing dangerous backtracking regular expressions in favor of RE2: https://github.com/google/re2/wiki/Syntax
    comment by jorangreef · 2019-07-30 · in What’s New in ES2019
  26. …[3] https://cs.chromium.org/search/?q=DCHECK%5C(+case:yes&sq=pac... [4] https://github.com/google/re2/blob/master/util/logging.h [5] http://huonw.github.io/blog/2016/04/myths-and-legends-about-... [6] https://dxr.mozilla.org/mozil
  27. Just to note Go Lang uses RE2 in its regexp[1]. [1]: https://github.com/google/re2/wiki/Syntax
    comment by Abishek_Muthian · 2019-07-13 · in Details of the Cloudflare outage on July 2, 2019
  28. …suffer this problem, but apparently they don't use it here? https://github.com/cloudflare/lua-re2 https://github.com/google/re2 https://github.com/google/re2/wiki/WhyRE2
  29. You probably want a regex engine that runs in linear time: * Google's RE2 https://github.com/google/re2/wiki/WhyRE2 * https://github.com/laurikari/tre/ There is a good series of articles about the problem:…
  30. …context, and it handles the DFA issue by simply putting an 8MB limit on the DFA for a regex: https://github.com/google/re2/blob/master/re2/re2.h#L601 I learned a few months ago that Rust's regex crate, which is based heavily on RE2, does…
  31. https://github.com/google/re2 is probably a better matched library by Google since the post focuses on truly regular expressions and a lot of irregexp's design is around making the irregular part not as costly.
  32. ▲ 1
    RE2: Safe RegExp
    story by novaleaf · 2019-02-19 · 0 comments
  33. …Random files from each of them: https://github.com/google/leveldb/blob/master/table/table_bu... https://github.com/google/re2/blob/master/re2/nfa.cc
  34. …just use PCRE through the C++ wrapper[2], but that hasn't been a common need in my experience. [1] https://github.com/google/re2/ [2] https://www.pcre.org/original/doc/html/pcrecpp.html
    comment by alexhutcheson · 2018-04-05 · in A meta-analysis of C++ projects
  35. Great observation, but re2 does have tradeoffs to gain that performance. Backreferences, for example: https://github.com/google/re2/issues/101
    comment by tyingq · 2018-02-14 · in Speed improvements in Python 3.7
  36. …tool that lets us confidently use complex regexes in production. https://pypi.python.org/pypi/re2/ https://github.com/google/re2/wiki/WhyRE2 > RE2 was designed and implemented with an explicit goal of being able to handle regular…
    comment by btown · 2018-02-13 · in Speed improvements in Python 3.7
  37. Here is the reference implementation for Russ Cox's work: https://github.com/google/re2
  38. …rewrite that part of the code to not rely on constantly parsing file paths? Or use something like https://github.com/google/re2 , you probably won't be able to do any better than that when doing any kind of string matching and parsing. If…
    comment by iamleppert · 2017-11-23 · in Improving Ruby Performance with Rust
  39. …match a given URL: https://github.com/nurettin/pwned/blob/master/server/server.... FilteredRE2 https://github.com/google/re2/blob/master/re2/filtered_re2.h
    comment by nurettin · 2017-11-10 · in LibHTTP: Open Source HTTP Library in C
  40. guarantee worst-case linear time matching for any number of expressions Or you could just use RE2: https://github.com/google/re2/wiki/WhyRE2 It's open source, and match time is linear in the length of the input string. (Disclosure: I work…
  41. Another good example is RE2: https://github.com/google/re2 It's pretty fast too. I don't know whether you can compare the performance of Ragel to regex libraries like RE2; they look like they solve different problems.
    comment by tantalor · 2016-08-15 · in Tyre – Typed regular expressions
  42. ▲ 2
    RE2: A fast, safe, thread-friendly alternative to backtracking regex
    story by scrollaway · 2016-07-20 · 0 comments
  43. Is this the sort of thing that https://github.com/google/re2 was made to solve?
    comment by selckin · 2016-07-20 · in Stack Overflow Outage Postmortem
  44. …pretty standard example: https://en.wikipedia.org/wiki/Regular_expression#Expressive_... See also: https://github.com/google/re2/blob/master/re2/testing/dfa_te... This blurb from Wikipedia is also relevant: > On the other hand, it is known…
  45. …is using it though, but a library called "re2". Never heard of it before. Googling turned up this https://github.com/google/re2
    comment by petke · 2016-01-12 · in Two Weeks of Rust
  46. https://github.com/google/re2/blob/master/re2/set.h <-- c++ API https://github.com/google/re2/blob/master/re2/prog.h#L339 <-- c
    comment by willvarfar · 2015-11-20 · in Python's Hidden Regular Expression Gems
  47. …fit for you, but it's not strictly true that RE2 can't tell you about multi-pattern matching. https://github.com/google/re2/blob/master/re2/set.h
  48. …falls over flat[1]. EDIT: Looks like the original linked page was first published in 2001[2]. [0] https://github.com/google/re2 [1] https://swtch.com/~rsc/regexp/regexp1.html [2] https://web.archive.org/web/*/http://perl.plover.com/NPC/
  49. Google has a similar library with similar goals. See https://github.com/google/re2/wiki/CplusplusAPI It also removes backtracking. The idea is that backtracking may kill performance, so a specially crafted text that causes a lot of…
    comment by nine_k · 2015-09-13 · in Perl Incompatible Regular Expressions
  50. ▲ 1
    RE2 Regex Syntax
    story by eatonphil · 2015-09-10 · 0 comments