Regular Expressions 101

Save & Manage Regex

  • Current Version: 1
  • Save & Share
  • Community Library

Flavor

  • PCRE2 (PHP)
  • ECMAScript (JavaScript)
  • Python
  • Golang
  • Java
  • .NET 7.0 (C#)
  • Rust
  • PCRE (Legacy)
  • Regex Flavor Guide

Function

  • Match
  • Substitution
  • List
  • Unit Tests (1)
Sponsors
An explanation of your regex will be automatically generated as you type.
Detailed match information will be displayed here automatically.
  • All Tokens
  • Common Tokens
  • General Tokens
  • Anchors
  • Meta Sequences
  • Quantifiers
  • Group Constructs
  • Character Classes
  • Flags/Modifiers
  • Substitution
  • A single character of: a, b or c
    [abc]
  • A character except: a, b or c
    [^abc]
  • A character in the range: a-z
    [a-z]
  • A character not in the range: a-z
    [^a-z]
  • A character in the range: a-z or A-Z
    [a-zA-Z]
  • Character class intersection
    [\w&&[^\d]]
  • Any single character
    .
  • Alternate - match either a or b
    a|b
  • Any whitespace character
    \s
  • Any non-whitespace character
    \S
  • Any digit
    \d
  • Any non-digit
    \D
  • Any word character
    \w
  • Any non-word character
    \W
  • Non-capturing group
    (?:...)
  • Capturing group
    (...)
  • Zero or one of a
    a?
  • Zero or more of a
    a*
  • One or more of a
    a+
  • Exactly 3 of a
    a{3}
  • 3 or more of a
    a{3,}
  • Between 3 and 6 of a
    a{3,6}
  • Start of string
    ^
  • End of string
    $
  • A word boundary
    \b
  • Non-word boundary
    \B

Regular Expression
Processing...

Test String

Code Generator

Generated Code

const regex = /(?:([A-Z]{2}|N\s|E\s|--)((?:[A-Z0-9\.\-\:\/])+)?)/g; // Alternative syntax using RegExp constructor // const regex = new RegExp('(?:([A-Z]{2}|N\\s|E\\s|--)((?:[A-Z0-9\\.\\-\\:\\\/])+)?)', 'g') const str = `JB,NMGORN,DT12-20-2021,TM13:45:31 MO,AD0,UN1,SF1.00000000,EC0,EO0.0,AU0 --SurvCE Version 5.06 --CRD: Alphanumeric --Определено пользователем : Russia MSC/MSK67-1 --Equipment: Stonex, S9i, SN:S900281900075, FW:0.22.181113(STONEX) --Antenna Type: [STXS9I NONE],RA0.0795m,SHMP0.0598m,L10.0850m,L20.0784m,--Integrated GPS L1/L2+L2C/L5, GLO, GAL, B --Файл локализации: \\Storage Card\\SurvCE\\Data\\67-1\\LOC\\SAF.loc --Число используемых точек локализации: 1 --Файл разделения геоида: Нет --Grid Adjustment File: Нет --Азимут локализации: State Plane Grid --GPS Масштаб: 1.00000000 --Scale Point not used --RTK Method: RTCM V3.0, Device: Встроенный GSM, Network: NTRIP MOZH_MSM4 BP,PN349,LA55.064900710960,LN33.141888559304,EL250.5740,AG0.0000,PA0.1339,ATAPC,SRROVER,-- --Entered Rover HR: 2.0000 m, Vertical LS,HR2.0850 GPS,PN1,LA55.090990117800,LN33.140386268200,EL253.819667,--Z --GS,PN1,N 501704.1625,E 1297999.7118,EL235.0189,--Z --GT,PN1,SW2189,ST121532000,EW2189,ET121536000 --Valid Readings: 3 of 3 --Fixed Readings: 3 of 3 --Nor Min: 501704.1606 Max: 501704.1638 --Eas Min: 1297999.7109 Max: 1297999.7125 --Elv Min: 235.0173 Max: 235.0203 --Nor Avg: 501704.1625 SD: 0.0014 --Eas Avg: 1297999.7118 SD: 0.0006 --Elv Avg: 235.0189 SD: 0.0012 --NRMS Avg: 0.0100 SD: 0.0000 Min: 0.0100 Max: 0.0100 --ERMS Avg: 0.0100 SD: 0.0000 Min: 0.0100 Max: 0.0100 --HSDV Avg: 0.0141 SD: 0.0000 Min: 0.0141 Max: 0.0141 --VSDV Avg: 0.0200 SD: 0.0000 Min: 0.0200 Max: 0.0200 --HDOP Avg: 0.6000 Min: 0.6000 Max: 0.6000 --VDOP Avg: 2.1060 Min: 2.1060 Max: 2.1060 --PDOP Avg: 2.1898 Min: 2.1898 Max: 2.1898 --Number of Satellites Avg: 19 Min: 19 Max: 19 --HSDV:0.014, VSDV:0.020, STATUS:FIXED, SATS:19, AGE:1.0, PDOP:2.190, HDOP:0.600, VDOP:2.106, TDOP:1.816, GDOP:1.224, NSDV:0.010, ESDV:0.010 --DT12-20-2021 --TM13:45:33 GPS,PN2,LA55.091082727600,LN33.140317462800,EL254.037667,--Z --GS,PN2,N 501732.6693,E 1297987.2197,EL235.2368,--Z --GT,PN2,SW2189,ST121580000,EW2189,ET121584000 --Valid Readings: 3 of 3 --Fixed Readings: 3 of 3 --Nor Min: 501732.6680 Max: 501732.6704 --Eas Min: 1297987.2181 Max: 1297987.2209 --Elv Min: 235.2281 Max: 235.2431 --Nor Avg: 501732.6693 SD: 0.0010 --Eas Avg: 1297987.2197 SD: 0.0012 --Elv Avg: 235.2368 SD: 0.0063 --NRMS Avg: 0.0100 SD: 0.0000 Min: 0.0100 Max: 0.0100 --ERMS Avg: 0.0100 SD: 0.0000 Min: 0.0100 Max: 0.0100 --HSDV Avg: 0.0141 SD: 0.0000 Min: 0.0141 Max: 0.0141 --VSDV Avg: 0.0200 SD: 0.0000 Min: 0.0200 Max: 0.0200 --HDOP Avg: 0.7000 Min: 0.7000 Max: 0.7000 --VDOP Avg: 2.1060 Min: 2.1060 Max: 2.1060 --PDOP Avg: 2.2193 Min: 2.2193 Max: 2.2193 --Number of Satellites Avg: 18 Min: 18 Max: 18 --HSDV:0.014, VSDV:0.020, STATUS:FIXED, SATS:18, AGE:1.0, PDOP:2.219, HDOP:0.700, VDOP:2.106, TDOP:1.851, GDOP:1.224, NSDV:0.010, ESDV:0.010 --DT12-20-2021 --TM13:46:11 GPS,PN3,LA55.091112958000,LN33.140291683000,EL253.961333,--P --GS,PN3,N 501741.9684,E 1297982.5540,EL235.1604,--P --GT,PN3,SW2189,ST121608000,EW2189,ET121612000 --Valid Readings: 3 of 3 --Fixed Readings: 3 of 3 --Nor Min: 501741.9661 Max: 501741.9701 --Eas Min: 1297982.5507 Max: 1297982.5578 --Elv Min: 235.1570 Max: 235.1640 --Nor Avg: 501741.9684 SD: 0.0017 --Eas Avg: 1297982.5540 SD: 0.0029 --Elv Avg: 235.1604 SD: 0.0029 --NRMS Avg: 0.0100 SD: 0.0000 Min: 0.0100 Max: 0.0100 --ERMS Avg: 0.0100 SD: 0.0000 Min: 0.0100 Max: 0.0100 --HSDV Avg: 0.0141 SD: 0.0000 Min: 0.0141 Max: 0.0141 --VSDV Avg: 0.0267 SD: 0.0047 Min: 0.0200 Max: 0.0300 --HDOP Avg: 0.9000 Min: 0.9000 Max: 0.9000 --VDOP Avg: 2.1060 Min: 2.1060 Max: 2.1060 --PDOP Avg: 2.2902 Min: 2.2902 Max: 2.2902 --Number of Satellites Avg: 15 Min: 15 Max: 16 --HSDV:0.014, VSDV:0.030, STATUS:FIXED, SATS:16, AGE:1.0, PDOP:2.290, HDOP:0.900, VDOP:2.106, TDOP:1.936, GDOP:1.224, NSDV:0.010, ESDV:0.010 --DT12-20-2021 --TM13:46:40`; // Reset `lastIndex` if this regex is defined globally // regex.lastIndex = 0; let m; while ((m = regex.exec(str)) !== null) { // This is necessary to avoid infinite loops with zero-width matches if (m.index === regex.lastIndex) { regex.lastIndex++; } // The result can be accessed through the `m`-variable. m.forEach((match, groupIndex) => { console.log(`Found match, group ${groupIndex}: ${match}`); }); }

Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for JavaScript, please visit: https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions