Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Regular Expression Tester for Google RE2 [closed]

Tags:

regex

re2

I'm looking for a regular expression tester for Google Big Data (RE2) reg expressions. There are a few testers out there, but none of them seems to understand my statement. These are the ones I've tried and they've worked for simple expressions but not with mine:

  • https://regex101.com/
  • https://www.regextester.com
  • https://www.analyticsmarket.com/freetools/regex-tester/

This is my regex:

^(?:1-)?((?:R|RO|Ro)?[:|.]?\\s?\\d{3}[-|.]?\\d{4}[-|/]F\\d{2}-\\d{2})$

where I would process strings like these:

  • Ro 708-2859/F07-01
  • RO708-2859-F06-04
  • RO703-3877-F01
  • 1-RO520-0628-F08
  • RO6868847-000-010

Does anyone have an idea of how I might enter the statement different or where I could test it?

like image 451
devnull Avatar asked Jan 29 '26 21:01

devnull


1 Answers

You can use

^(?:1-)?((?:R[Oo]?)?[:.]?\s?\d{3}[-.]?\d{4}[-/](?:F\d{2}(?:-\d{2})?|\d{3}[-/]\d{3}))$

See the regex demo. Details:

  • ^ - start of string
  • (?:1-)? - an optional 1- string
  • ((?:R[Oo]?)?[:.]?\s?\d{3}[-.]?\d{4}[-/](?:F\d{2}(?:-\d{2})?|\d{3}[-/]\d{3})) - Group 1:
    • (?:R[Oo]?)? - an optional sequence of R and then an optional O or o
    • [:.]? - an optional : or .
    • \s? - an optional whitespace
    • \d{3} - three digits
    • [-.]? - an optional - or .
    • \d{4} - four digits
    • [-/] - - or /
    • (?:F\d{2}(?:-\d{2})?|\d{3}[-/]\d{3}) - either F, two digits and then an optional sequence of - and two digits, or three digits, - or / and three digits
  • $ - end of string.

See the Google Sheets demo:

enter image description here

like image 108
Wiktor Stribiżew Avatar answered Feb 03 '26 08:02

Wiktor Stribiżew