Regular Expressions 101

Save & Share

  • Regex Version: ver. 1
  • Update Regex
    ctrl+⇧+s
  • Save new Regex
    ctrl+s
  • Add to Community Library

Flavor

  • PCRE2 (PHP >=7.3)
  • PCRE (PHP <7.3)
  • ECMAScript (JavaScript)
  • Python
  • Golang
  • Java 8
  • .NET 7.0 (C#)
  • Rust
  • Regex Flavor Guide

Function

  • Match
  • Substitution
  • List
  • Unit Tests

Tools

Sponsors
There are currently no sponsors. Become a sponsor today!
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]
  • 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
No Match

/
/
gm

Test String

Code Generator

Generated Code

const regex = /(?<=\d{4}\.\d{3}\.\d{3}.*).*\n(.+)/gm; // Alternative syntax using RegExp constructor // const regex = new RegExp('(?<=\\d{4}\\.\\d{3}\\.\\d{3}.*).*\\n(.+)', 'gm') const str = `Number 5012993885 Transport 23943538 Contact person Lenka Boček E-Mail Date 24.01.2024 Telephone 00420 731316628 Your VAT No. BG175423111 Shipment by Parcel service Forwarder UPS United Parcel Service Item Part Number Description Suffix Quantity Piece Price/ EUR Per PCE Disc.% Amount EUR Customer Material / Material entered / OE-Number Transport: 23943538 Order No.: 3192166 Your Reference: A202401241118 11 4149.310.025 000 1 37,78 1 37,78 PISTON HS.code: 87084099 Country of origin: EU/DE EAN: 2050000141478 21 0734.401.251 000 4 3,05 1 12,20 PISTON RING HS.code: 73182100 Country of origin: JP EAN: 2050000026638 31 0750.116.391 000 1 35,50 1 35,50 BALL BEARING HS.code: 84821090 Country of origin: JP EAN: 2050000088643 41 0634.314.358 000 1 5,57 1 5,57 O-RING HS.code: 39269097 Country of origin: EU/IT EAN: 2050000017476 51 0734.401.080 000 1 5,41 1 5,41 PISTON RING HS.code: 73182100 Country of origin: JP EAN: 2050000028885 61 4139.210.082 000 1 55,70 1 55,70 BUSH HS.code: 73182900 Country of origin: EU/DE EAN: 2050000111631 Number 5012993885 Date 24.01.2024 carry forward 152,16 Item Part Number Description Suffix Quantity Piece Price/ EUR Per PCE Disc.% Amount EUR Customer Material / Material entered / OE-Number 71 0734.401.277 000 1 110,41 1 110,41 RECTANGULAR RING HS.code: 73182100 Country of origin: QU EAN: 2050000103230 81 0634.313.017 000 1 0,81 1 0,81 O-RING HS.code: 39269097 Country of origin: EU/IT EAN: 2050000057557 91 4149.320.018 000 1 79,19 1 79,19 BUSH HS.code: 76169990 Country of origin: EU/DE EAN: 2050000144653 101 0750.115.518 000 1 2,16 1 2,16 NEEDLE SLEEVE HS.code: 84824000 Country of origin: EU/DE EAN: 2050000086328 111 0730.150.625 000 1 3,67 1 3,67 THRUST WASHER HS.code: 39269097 Country of origin: EU/DE EAN: 2050000082290 121 0750.115.520 000 2 5,97 1 11,94 NEEDLE CAGE HS.code: 84824000 Country of origin: EU/SK EAN: 2050000116179 131 0730.150.638 000 1 5,98 1 5,98 THRUST WASHER HS.code: 39269097 Country of origin: EU/DE EAN: 2050000104367 141 0730.150.630 000 1 12,98 1 12,98 THRUST WASHER HS.code: 39269097 Country of origin: EU/DE EAN: 2050000112317 151 0735.320.782 000 2 8,76 1 17,52 NEEDLE CAGE HS.code: 84824000 Country of origin: EU/SK EAN: 2050000060595 161 0730.150.637 000 1 4,67 1 4,67 THRUST WASHER HS.code: 39269097 Country of origin: EU/DE EAN: 2050000115325 171 0730.150.636 000 1 6,82 1 6,82 THRUST WASHER HS.code: 39269097 Country of origin: EU/DE EAN: 2050000082610 181 0730.150.639 000 1 3,55 1 3,55 THRUST WASHER HS.code: 39269097 Country of origin: EU/DE EAN: 2050000054846 191 0750.115.519 000 1 4,06 1 4,06 NEEDLE SLEEVE HS.code: 84824000 Country of origin: US EAN: 2050000080418 201 4139.333.040 000 1 2,10 1 2,10 FIXING PLATE HS.code: 87084099 Country of origin: EU/DE EAN: 2050000043369 Item Part Number Description Suffix Quantity Piece Price/ EUR Per PCE Disc.% Amount EUR Customer Material / Material entered / OE-Number 211 0630.513.028 000 1 1,25 1 1,25 SNAP RING HS.code: 73182100 Country of origin: EU/IT EAN: 2050000007927 221 4139.333.373 000 1 18,43 1 18,43 DISC HS.code: 87084099 Country of origin: EU/DE EAN: 2050000055355 231 4139.333.172 000 1 13,40 1 13,40 O.CLUTCH DISC HS.code: 87084099 Country of origin: EU/DE EAN: 2050000139765 241 4139.333.036 000 1 4,55 1 4,55 I.CLUTCH DISC HS.code: 87084099 Country of origin: EU/DE EAN: 2050000132223 251 4149.370.005 000 1 12,96 1 12,96 O.CLUTCH DISC HS.code: 87084099 Country of origin: EU/DE EAN: 2050000134135 261 4139.333.437 000 1 18,36 1 18,36 DISC HS.code: 87084099 Country of origin: EU/DE EAN: 2050000071713 271 4139.333.263 000 1 17,98 1 17,98 O.CLUTCH DISC HS.code: 87084099 Country of origin: EU/DE EAN: 2050000104916 281 4139.333.745 000 3 17,05 1 51,15 O.CLUTCH DISC HS.code: 87084099 Country of origin: EU/DE EAN: 2050000143649 291 4139.333.766 000 1 21,36 1 21,36 O.CLUTCH DISC HS.code: 87084099 Country of origin: EU/DE EAN: 2050000081705 301 0734.307.302 000 1 18,92 1 18,92 LIP SEALING RING HS.code: 84842000 Country of origin: EU/DE EAN: 2050000176593 311 0734.300.504 000 1 15,46 1 15,46 PISTON RING HS.code: 39269097 Country of origin: EU/DE EAN: 2050000174032 321 0734.300.503 000 1 12,19 1 12,19 PISTON RING HS.code: 39269097 Country of origin: EU/DE EAN: 2050000176807 331 0750.117.625 000 1 31,26 1 31,26 TAPERED ROLLER BEARING HS.code: 84822000 Country of origin: CN EAN: 2050000123405 341 0730.103.590 000 1 2,79 1 2,79 WASHER HS.code: 73182200 Country of origin: EU/DE EAN: 2050000109447 carry forward 658,08 4/7 Item Part Number Description Suffix Quantity Piece Price/ EUR Per PCE Disc.% Amount EUR Customer Material / Material entered / OE-Number 351 0730.103.589 000 1 2,00 1 2,00 WASHER HS.code: 73182200 Country of origin: EU/DE EAN: 2050000099366 361 0750.117.621 000 1 32,82 1 32,82 TAPERED ROLLER BEARING HS.code: 84822000 Country of origin: JP EAN: 2050000124365 371 0730.103.362 000 1 7,67 1 7,67 SPACER WASHER HS.code: 73182200 Country of origin: EU/DE EAN: 2050000071355 381 0730.008.417 000 1 3,02 1 3,02 WASHER HS.code: 73182200 Country of origin: EU/DE EAN: 2050006139165 391 0730.008.418 000 1 3,02 1 3,02 WASHER HS.code: 73182200 Country of origin: EU/DE EAN: 2050000101281 401 0730.008.420 000 1 4,31 1 4,31 WASHER HS.code: 73182200 Country of origin: EU/DE EAN: 2050000158292 411 0730.008.423 000 1 3,02 1 3,02 WASHER HS.code: 73182200 Country of origin: EU/DE EAN: 2050000052804 421 0634.313.016 000 2 0,34 1 0,68 O-RING HS.code: 39269097 Country of origin: EU/IT EAN: 2050000024382 431 0730.002.769 000 7 0,74 1 5,18 WASHER HS.code: 73182200 Country of origin: EU/DE EAN: 2050000109171 441 0630.502.007 000 7 0,41 1 2,87 CIRCLIP HS.code: 73182100 Country of origin: CN EAN: 2050000012969 451 4139.306.217 000 7 7,95 1 55,65 PIN HS.code: 73170080 Country of origin: EU/DE EAN: 2050000093951 461 0501.214.850 000 1 68,29 1 68,29 OIL DIPSTICK HS.code: 90261089 Country of origin: EU/DE EAN: 2050000096211 471 4139.301.617 000 1 0,70 1 0,70 TAB WASHER HS.code: 73182100 Country of origin: EU/DE EAN: 2050000084041 481 0769.151.009 000 1 1,87 1 1,87 O-RING HS.code: 39269097 Country of origin: EU/IT EAN: 2050011096262 carry forward 849,18 5/7 carry forward 849,18 Item Part Number Description Suffix Quantity Piece Price/ EUR Per PCE Disc.% Amount EUR Customer Material / Material entered / OE-Number 491 0501.210.798 000 1 10,08 1 10,08 SCREEN INSERT HS.code: 87084099 Country of origin: EU/IT EAN: 2050000005534 501 0735.368.102 000 1 70,18 1 70,18 AXIAL ROLLER BEARING HS.code: 84825000 Country of origin: EU/SK EAN: 2050000123191 511 0635.330.035 000 2 25,15 1 50,30 BALL BEARING HS.code: 84821090 Country of origin: IN EAN: 2050000051746 521 0635.900.523 000 1 8,94 1 8,94 AX.NEEDLE CAGE HS.code: 84829900 Country of origin: EU/DE EAN: 2050000012099 531 0634.402.140 000 1 3,22 1 3,22 R-RING HS.code: 73262000 Country of origin: JP EAN: 2050000102523 541 0501.213.150 000 2 52,97 1 105,94 I.CLUTCH DISC HS.code: 87084099 Country of origin: EU/PL EAN: 2050000017186 551 0501.334.482 000 2 91,72 1 183,44 OUTER CLUTCH DISK HS.code: 87084099 Country of origin: EU/DE EAN: 2050011198423 561 0501.334.483 000 2 116,68 1 233,36 OUTER CLUTCH DISK HS.code: 87084099 Country of origin: EU/DE EAN: 2050011198416 571 0750.106.074 000 1 124,26 1 124,26 CUP SPRING HS.code: 73209030 Country of origin: EU/DE EAN: 2050000062230 581 0501.320.311 000 1 16,72 1 16,72 SEALING RING HS.code: 40169300 Country of origin: EU/IE EAN: 2050000006746 591 0501.320.312 000 1 27,75 1 27,75 SEALING RING HS.code: 40169300 Country of origin: EU/IE EAN: 2050000021688 601 0634.313.840 000 1 15,01 1 15,01 O-RING HS.code: 39269097 Country of origin: EU/IT EAN: 2050000043406 611 0736.101.046 000 1 3,91 1 3,91 CAP SCREW HS.code: 73181568 Country of origin: EU/DE EAN: 2050000066542 621 0730.005.592 000 1 11,45 1 11,45 WASHER HS.code: 73182200 Country of origin: EU/DE EAN: 2050000028366 carry forward 1.713,74 6/7 Item Part Number Description Suffix Quantity Piece Price/ EUR Per PCE Disc.% Amount EUR Customer Material / Material entered / OE-Number 631 0634.313.628 000 2 1,76 1 3,52 O-RING HS.code: 39269097 Country of origin: EU/IT EAN: 2050000092503 641 0501.221.565 000 1 111,27 1 111,27 PISTON HS.code: 87084099 Country of origin: EU/DE EAN: 2050010978361 651 4139.347.284 000 1 1,32 1 1,32 GASKET HS.code: 40169300 Country of origin: EU/DE EAN: 2050000074042 661 4139.347.275 000 2 0,69 1 1,38 GASKET HS.code: 40169300 Country of origin: EU/DE EAN: 2050005683713 671 4139.347.273 000 2 77,93 1 155,86 CONN.PART HS.code: 87084099 Country of origin: EU/DE EAN: 2050001798787 681 4139.298.939 009 1 52,37 1 52,37 SEALING RING KIT HS.code: 84849000 Country of origin: EU/DE EAN: 4053202129457 691 4139.298.943 009 1 115,37 1 115,37 SEAL KIT HS.code: 84849000 Country of origin: EU/DE EAN: 4053202129426 Goods value: 2.154,83 Freight charges 14,45 Transport: 23943551 711 0630.361.026 000 1 6,82 1 6,82 SEALING CAP HS.code: 73269098 Country of origin: EU/DE EAN: 2050000286988 721 0634.303.110 000 1 2,62 1 2,62 O-RING HS.code: 40169300 Country of origin: EU/IT EAN: 2050000069956 731 0634.316.304 000 1 3,77 1 3,77 O-RING HS.code: 39269097 Country of origin: EU/IT EAN: 2050000014369 Goods value: 13,21 Freight charges 24,40 Subtotal 2.168,04 Freight charges 38,85 Total amount 2.206,89 Terms of payment Up to 07.02.2024 you receive 2,000 % discount Up to 24.03.2024 without deduction Tax free supply within the EEC in terms of §6a VAT Law. Packaging 2 collies Gross weight/kg 19,00 Net weight/kg 17,50 Marks:7/7 `; // 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