Questions tagged [re2]

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

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

Backtracking engines are typically full of features and convenient syntactic sugar but can be forced into taking exponential amounts of time on even small inputs. RE2 uses automata theory to guarantee that regular expression searches run in time linear in the size of the input. RE2 implements memory limits, so that searches can be constrained to a fixed amount of memory. RE2 is engineered to use a small fixed C++ stack footprint no matter what inputs or regular expressions it must process; thus RE2 is useful in multithreaded environments where thread stacks cannot grow arbitrarily large.

When RE2 was released, Russ Cox the main author of RE2, published a series of articles on the CS theory and real world implementation of regular expressions. Including some in depth benchmarks of RE2 vs competing regex libraries.

Bindings for some scripting languages languages exist for Python and Ruby.

Supported syntax can be found here.

382 questions
0
votes
1 answer

How does golang do with complicated regexp pattern

I wanna replace all ANSI/VT100/xterm control sequences output by shell in golang And i searched this regexp pattern here, but it doesn't work! here is error: panic: regexp: Compile(`[\b]`): error parsing regexp: invalid escape sequence: `\b` code…
nullne co
  • 53
  • 5
0
votes
2 answers

re2 regex expression that starts with From: and ends with domain.com

I'm trying to come up with a regex expression I can use for filtering incoming email to my Google Apps domain. I'm using Content Compliance to check if it's signed using DKIM and then see if the "From:" part of the header contains our domain name.…
0
votes
0 answers

Find All Git Sendmail Cover Letters Using A Regex In Gmail

I'm trying to get... \[(RFC )?(PATCH )(RFC )?([vV]\d+ )?(0+\/\d+)\] Which matches the likes of: [PATCH v1 000/100] Test [PATCH 0/2] Test [PATCH 00/11] Test [RFC PATCH 0/7] Test [PATCH V1 000/100] Test [PATCH RFC 0/7] Test ...working as a Gmail…
0
votes
1 answer

Get matched data out of re2 Arg

I'm trying to use re2 but couldn't see how I get the matched data out of the RE2::Arg[] when the number of matches in the regex are determined at run time. I have something like this: const RE2::Arg *args[10] = {}; int n = 0; if…
zcourts
  • 4,863
  • 6
  • 49
  • 74
0
votes
1 answer

How to get all possible interpretations in regex match?

If "Who acted as (?P.*) in (?P.*)" is the template I want to match for queries like "Who acted as tony montana in Scarface". If the role name has a "in" here or If the movie name has an "in", the regex match will go wrong. Eg: "Who…
nizam.sp
  • 4,002
  • 5
  • 39
  • 63
0
votes
0 answers

Segmentation fault for pthreads in shared library

I implement an application which used shared library with pthreads. App <- lib1.so <- re2.so. Only re2.so uses pthreads. lib1.so depend from lib2.so, App depend from lib1.so. re2.so - regular expression library. After execution the main function I…
serkos
  • 306
  • 1
  • 4
0
votes
2 answers

Does Re2 use string size or null termination?

The title is pretty much it. If a standard C++ string with UTF-8 characters has no zero bytes does the scanning terminate at the end of the string defined by it's size? Conversely, if the string has a zero byte does scanning stop at that byte, or…
0
votes
1 answer

Followup: Error: Failed to parse regular expression “”: pattern too large - compile failed

This is a followup on Error: Failed to parse regular expression "": pattern too large - compile failed... I am hitting this problem again. Can anyone please please explain how BigQuery allocates resources for REGEXP functions? Is there a known…
N.N.
  • 3,094
  • 21
  • 41
0
votes
1 answer

regex \w seems to fail on re2

In the re2 header it says // C++ interface to the re2 regular-expression library. // RE2 supports Perl-style regular expressions (with extensions like // \d, \w, \s, ...). I notice my pattern failing then notice \w doesn't seem to work. here is my…
user34537
0
votes
1 answer

re2 does not seem to give correct results for some patterns when compared to pcre

I was trying to use both pcre and re2 and I came up with the following observation. When I give the string as "ab cd" and the pattern as "^[^c]" re2 returns NO MATCH but its actually a match. That is to say when I type this RE2::FullMatch("ab…
Atanu
  • 61
  • 2
  • 12
-1
votes
1 answer

regex to extract sentence to the left of a word but not include words with dashes as whole words

I am trying to extract everything to the left of pin_delim. This works fine for id 1,2,3,6 but fails for 5. id 4 is expected to return no results. I can figure out how to stop pin_delim spliting on a dash -? Any ideas on how to fix this and why is -…
dpl
  • 27
  • 5
-1
votes
1 answer

Regular expression that matches a pattern as well as any number of comma space separated repetitions

What regular expression matches the below a pattern that's composed of two letters and numbers any comma-space repetitions of said pattern Assume the below cells, their contents and the times the pattern is…
Miltos
  • 23
  • 5
-1
votes
1 answer

Regex TRYING to search with multiple criteria or backwards

Appreciating regex but still beginning. I tried many workarounds but can't figure how to solve my problem. String A : 4 x 120glgt String B : 120glgt I'd like the proper regex to return 120 as the number after "x". But sometimes there won't be "x".…
-1
votes
1 answer

Google data Studio REGEX_MATCH - How to extract string from between strings?

I have a url which is as follows www.abc.com?utm_term=stack%20overflow&device=mobile I need to extract stack%20overflow from with the url. I have tried everything but it doesn't work. Any help is appreciated. I tried the following it doesn't…
jarvis
  • 157
  • 1
  • 13
-1
votes
1 answer

How can I extract an ID from an URL in Datastudio?

My task is to create a new Dimension that contains all IDs. I`ve got 50 IDs that I need to Extract from URLs. The URLs are in the dimension "seite"(page). I already know all the IDs (example IDs: S121314, s232425). The URL’s look like this:…
Elno
  • 13
  • 1