Regular Expressions 101

Save & Share

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
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
  • Match everything enclosed
    (?:...)
  • Capture everything enclosed
    (...)
  • 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

/
/
gm

Test String

Code Generator

Generated Code

const regex = /(\d)\n([\d.]+)\n([\d, ]+)\n([\d, ]+)\n([\d, ]+)\n([\d, ]+)\n([\d,]+)\n([-\d, ]+)$/gm; // Alternative syntax using RegExp constructor // const regex = new RegExp('(\\d)\\n([\\d.]+)\\n([\\d, ]+)\\n([\\d, ]+)\\n([\\d, ]+)\\n([\\d, ]+)\\n([\\d,]+)\\n([-\\d, ]+)$', 'gm') const str = `№;Дата;Месечна вноска;Вноска главница;Вноска лихва;Остатък главница;Такси и комисионни;Паричен поток 0 01.06.2021 0,00 0,00 0,00 140 000,00 246,00 139 754,00 1 01.07.2021 1 610,54 1 318,87 291,67 140 000,00 2,50 -1 613,04 2 01.08.2021 1 610,54 1 321,62 288,92 138 681,13 2,50 -1 613,04 3 01.09.2021 1 610,54 1 324,37 286,17 137 359,51 2,50 -1 613,04 4 01.10.2021 1 610,54 1 327,13 283,41 136 035,14 2,50 -1 613,04 5 01.11.2021 1 610,54 1 329,90 280,64 134 708,01 2,50 -1 613,04 6 01.12.2021 1 610,54 1 332,67 277,87 133 378,11 2,50 -1 613,04 7 01.01.2022 1 610,54 1 335,45 275,09 132 045,44 2,50 -1 613,04 8 01.02.2022 1 610,54 1 338,23 272,31 130 709,99 2,50 -1 613,04 9 01.03.2022 1 610,54 1 341,02 269,52 129 371,76 2,50 -1 613,04 10 01.04.2022 1 610,54 1 343,81 266,73 128 030,74 2,50 -1 613,04 11 01.05.2022 1 610,54 1 346,61 263,93 126 686,93 2,50 -1 613,04 12 01.06.2022 1 610,54 1 349,41 261,13 125 340,32 2,50 -1 613,04 13 01.07.2022 1 610,54 1 352,23 258,31 123 990,91 2,50 -1 613,04 14 01.08.2022 1 610,54 1 355,04 255,50 122 638,68 2,50 -1 613,04 15 01.09.2022 1 610,54 1 357,87 252,67 121 283,64 2,50 -1 613,04 16 01.10.2022 1 610,54 1 360,69 249,85 119 925,77 2,50 -1 613,04 17 01.11.2022 1 610,54 1 363,53 247,01 118 565,08 2,50 -1 613,04 18 01.12.2022 1 610,54 1 366,37 244,17 117 201,55 2,50 -1 613,04 19 01.01.2023 1 610,54 1 369,22 241,32 115 835,18 2,50 -1 613,04 20 01.02.2023 1 610,54 1 372,07 238,47 114 465,96 2,50 -1 613,04 21 01.03.2023 1 610,54 1 374,93 235,61 113 093,89 2,50 -1 613,04 22 01.04.2023 1 610,54 1 377,79 232,75 111 718,96 2,50 -1 613,04 23 01.05.2023 1 610,54 1 380,66 229,88 110 341,17 2,50 -1 613,04 24 01.06.2023 1 610,54 1 383,54 227,00 108 960,51 2,50 -1 613,04 25 01.07.2023 1 610,54 1 386,42 224,12 107 576,97 2,50 -1 613,04 26 01.08.2023 1 610,54 1 389,31 221,23 106 190,55 2,50 -1 613,04 27 01.09.2023 1 610,54 1 392,20 218,34 104 801,24 2,50 -1 613,04 28 01.10.2023 1 610,54 1 395,10 215,44 103 409,04 2,50 -1 613,04 29 01.11.2023 1 610,54 1 398,01 212,53 102 013,94 2,50 -1 613,04 30 01.12.2023 1 610,54 1 400,92 209,62 100 615,93 2,50 -1 613,04 31 01.01.2024 1 610,54 1 403,84 206,70 99 215,01 2,50 -1 613,04 32 01.02.2024 1 610,54 1 406,77 203,77 97 811,17 2,50 -1 613,04 33 01.03.2024 1 610,54 1 409,70 200,84 96 404,40 2,50 -1 613,04 34 01.04.2024 1 610,54 1 412,63 197,91 94 994,70 2,50 -1 613,04 35 01.05.2024 1 610,54 1 415,58 194,96 93 582,07 2,50 -1 613,04 36 01.06.2024 1 610,54 1 418,53 192,01 92 166,49 2,50 -1 613,04 37 01.07.2024 1 610,54 1 421,48 189,06 90 747,96 2,50 -1 613,04 38 01.08.2024 1 610,54 1 424,44 186,10 89 326,48 2,50 -1 613,04 39 01.09.2024 1 610,54 1 427,41 183,13 87 902,04 2,50 -1 613,04 40 01.10.2024 1 610,54 1 430,38 180,16 86 474,63 2,50 -1 613,04 41 01.11.2024 1 610,54 1 433,36 177,18 85 044,25 2,50 -1 613,04 42 01.12.2024 1 610,54 1 436,35 174,19 83 610,89 2,50 -1 613,04 43 01.01.2025 1 610,54 1 439,34 171,20 82 174,54 2,50 -1 613,04 44 01.02.2025 1 610,54 1 442,34 168,20 80 735,20 2,50 -1 613,04 45 01.03.2025 1 610,54 1 445,35 165,19 79 292,86 2,50 -1 613,04 46 01.04.2025 1 610,54 1 448,36 162,18 77 847,51 2,50 -1 613,04 47 01.05.2025 1 610,54 1 451,38 159,16 76 399,15 2,50 -1 613,04 48 01.06.2025 1 610,54 1 454,40 156,14 74 947,77 2,50 -1 613,04 49 01.07.2025 1 610,54 1 457,43 153,11 73 493,37 2,50 -1 613,04 50 01.08.2025 1 610,54 1 460,47 150,07 72 035,94 2,50 -1 613,04 51 01.09.2025 1 610,54 1 463,51 147,03 70 575,47 2,50 -1 613,04 52 01.10.2025 1 610,54 1 466,56 143,98 69 111,96 2,50 -1 613,04 53 01.11.2025 1 610,54 1 469,61 140,93 67 645,40 2,50 -1 613,04 54 01.12.2025 1 610,54 1 472,67 137,87 66 175,79 2,50 -1 613,04 55 01.01.2026 1 610,54 1 475,74 134,80 64 703,12 2,50 -1 613,04 56 01.02.2026 1 610,54 1 478,82 131,72 63 227,38 2,50 -1 613,04 57 01.03.2026 1 610,54 1 481,90 128,64 61 748,56 2,50 -1 613,04 58 01.04.2026 1 610,54 1 484,98 125,56 60 266,66 2,50 -1 613,04 59 01.05.2026 1 610,54 1 488,08 122,46 58 781,68 2,50 -1 613,04 60 01.06.2026 1 610,54 1 491,18 119,36 57 293,60 2,50 -1 613,04 61 01.07.2026 1 610,54 1 494,28 116,26 55 802,42 2,50 -1 613,04 62 01.08.2026 1 610,54 1 497,40 113,14 54 308,14 2,50 -1 613,04 63 01.09.2026 1 610,54 1 500,52 110,02 52 810,74 2,50 -1 613,04 64 01.10.2026 1 610,54 1 503,64 106,90 51 310,22 2,50 -1 613,04 65 01.11.2026 1 610,54 1 506,78 103,76 49 806,58 2,50 -1 613,04 66 01.12.2026 1 610,54 1 509,92 100,62 48 299,80 2,50 -1 613,04 67 01.01.2027 1 610,54 1 513,06 97,48 46 789,88 2,50 -1 613,04 68 01.02.2027 1 610,54 1 516,21 94,33 45 276,82 2,50 -1 613,04 69 01.03.2027 1 610,54 1 519,37 91,17 43 760,61 2,50 -1 613,04 70 01.04.2027 1 610,54 1 522,54 88,00 42 241,24 2,50 -1 613,04 71 01.05.2027 1 610,54 1 525,71 84,83 40 718,70 2,50 -1 613,04 72 01.06.2027 1 610,54 1 528,89 81,65 39 192,99 2,50 -1 613,04 73 01.07.2027 1 610,54 1 532,07 78,47 37 664,10 2,50 -1 613,04 74 01.08.2027 1 610,54 1 535,26 75,28 36 132,03 2,50 -1 613,04 75 01.09.2027 1 610,54 1 538,46 72,08 34 596,77 2,50 -1 613,04 76 01.10.2027 1 610,54 1 541,67 68,87 33 058,31 2,50 -1 613,04 77 01.11.2027 1 610,54 1 544,88 65,66 31 516,64 2,50 -1 613,04 78 01.12.2027 1 610,54 1 548,10 62,44 29 971,76 2,50 -1 613,04 79 01.01.2028 1 610,54 1 551,32 59,22 28 423,66 2,50 -1 613,04 80 01.02.2028 1 610,54 1 554,56 55,98 26 872,34 2,50 -1 613,04 81 01.03.2028 1 610,54 1 557,79 52,75 25 317,78 2,50 -1 613,04 82 01.04.2028 1 610,54 1 561,04 49,50 23 759,99 2,50 -1 613,04 83 01.05.2028 1 610,54 1 564,29 46,25 22 198,95 2,50 -1 613,04 84 01.06.2028 1 610,54 1 567,55 42,99 20 634,66 2,50 -1 613,04 85 01.07.2028 1 610,54 1 570,82 39,72 19 067,11 2,50 -1 613,04 86 01.08.2028 1 610,54 1 574,09 36,45 17 496,29 2,50 -1 613,04 87 01.09.2028 1 610,54 1 577,37 33,17 15 922,20 2,50 -1 613,04 88 01.10.2028 1 610,54 1 580,65 29,89 14 344,83 2,50 -1 613,04 89 01.11.2028 1 610,54 1 583,95 26,59 12 764,18 2,50 -1 613,04 90 01.12.2028 1 610,54 1 587,25 23,29 11 180,23 2,50 -1 613,04 91 01.01.2029 1 610,54 1 590,55 19,99 9 592,98 2,50 -1 613,04 92 01.02.2029 1 610,54 1 593,87 16,67 8 002,43 2,50 -1 613,04 93 01.03.2029 1 610,54 1 597,19 13,35 6 408,56 2,50 -1 613,04 94 01.04.2029 1 610,54 1 600,52 10,02 4 811,37 2,50 -1 613,04 95 01.05.2029 1 610,54 1 603,85 6,69 3 210,85 2,50 -1 613,04 96 01.06.2029 1 610,35 1 607,00 3,35 1 607,00 2,50 -1 612,85`; 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