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
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

/
/
gm

Test String

Code Generator

Generated Code

$re = '/(?<=^1\t)(.*?\t){1}/m'; $str = 'Polarization Analyzer Results No Stokes Comp. 1 Lin. PER [dB] Stokes Comp. 2 φ [°] Stokes Comp. 3 Intensity [%] φ [°] Comment Timestamp 1 0.326 0.1 -0.625 -31.2 -0.709 0.0 -31.2 comment is empty 20.12.2021, 17:10:07 2 -0.462 0.2 -0.869 -59.0 0.180 0.0 -59.0 comment is empty 20.12.2021, 17:10:08 3 0.915 0.2 -0.097 -3.0 -0.390 0.0 -3.0 comment is empty 20.12.2021, 17:10:09 No Stokes Comp. 1 Lin. PER [dB] Stokes Comp. 2 φ [°] Stokes Comp. 3 Intensity [%] φ [°] Comment Timestamp 1 -0.499 0.3 -0.839 -60.4 -0.214 0.0 -60.4 comment is empty 20.12.2021, 17:10:18 2 0.966 0.2 -0.208 -6.1 0.152 0.0 -6.1 comment is empty 20.12.2021, 17:10:19 3 -0.875 0.1 0.194 83.8 -0.444 0.0 83.8 comment is empty 20.12.2021, 17:10:20 No Stokes Comp. 1 Lin. PER [dB] Stokes Comp. 2 φ [°] Stokes Comp. 3 Intensity [%] φ [°] Comment Timestamp 1 -0.719 0.2 0.663 68.7 -0.206 0.0 68.7 comment is empty 20.12.2021, 17:10:30 2 -0.693 0.2 -0.578 -70.1 0.430 0.0 -70.1 comment is empty 20.12.2021, 17:10:31 3 -0.932 0.4 0.165 85.0 -0.322 0.0 85.0 comment is empty 20.12.2021, 17:10:32 No Stokes Comp. 1 Lin. PER [dB] Stokes Comp. 2 φ [°] Stokes Comp. 3 Intensity [%] φ [°] Comment Timestamp 1 0.630 0.2 0.233 10.2 -0.741 0.0 10.2 comment is empty 20.12.2021, 17:10:41 2 0.441 0.1 -0.438 -22.4 -0.784 0.0 -22.4 comment is empty 20.12.2021, 17:10:42 3 0.360 0.3 -0.919 -34.3 -0.159 0.0 -34.3 comment is empty 20.12.2021, 17:10:43 No Stokes Comp. 1 Lin. PER [dB] Stokes Comp. 2 φ [°] Stokes Comp. 3 Intensity [%] φ [°] Comment Timestamp 1 0.703 0.2 -0.689 -22.2 0.177 0.0 -22.2 comment is empty 20.12.2021, 17:10:53 2 0.898 0.2 0.072 2.3 -0.433 0.0 2.3 comment is empty 20.12.2021, 17:10:54 3 0.737 0.3 -0.510 -17.3 -0.443 0.0 -17.3 comment is empty 20.12.2021, 17:10:55 No Stokes Comp. 1 Lin. PER [dB] Stokes Comp. 2 φ [°] Stokes Comp. 3 Intensity [%] φ [°] Comment Timestamp 1 -0.199 0.1 -0.622 -53.9 -0.757 0.0 -53.9 comment is empty 20.12.2021, 17:11:04 2 -0.829 0.2 -0.466 -75.3 0.309 0.0 -75.3 comment is empty 20.12.2021, 17:11:05 3 -0.164 0.2 0.909 50.1 -0.384 0.0 50.1 comment is empty 20.12.2021, 17:11:06 No Stokes Comp. 1 Lin. PER [dB] Stokes Comp. 2 φ [°] Stokes Comp. 3 Intensity [%] φ [°] Comment Timestamp 1 -0.384 0.1 0.681 59.7 0.623 0.0 59.7 comment is empty 20.12.2021, 17:11:15 2 -0.144 0.3 -0.827 -49.9 -0.543 0.0 -49.9 comment is empty 20.12.2021, 17:11:16 3 0.594 0.3 -0.777 -26.3 -0.207 0.0 -26.3 comment is empty 20.12.2021, 17:11:17 No Stokes Comp. 1 Lin. PER [dB] Stokes Comp. 2 φ [°] Stokes Comp. 3 Intensity [%] φ [°] Comment Timestamp 1 -0.692 0.1 -0.459 -73.2 -0.557 0.0 -73.2 comment is empty 20.12.2021, 17:11:27 2 0.976 0.3 -0.061 -1.8 0.209 0.0 -1.8 comment is empty 20.12.2021, 17:11:28 3 0.477 0.1 -0.746 -28.7 0.465 0.0 -28.7 comment is empty 20.12.2021, 17:11:29 No Stokes Comp. 1 Lin. PER [dB] Stokes Comp. 2 φ [°] Stokes Comp. 3 Intensity [%] φ [°] Comment Timestamp 1 -0.278 0.3 0.922 53.4 -0.268 0.0 53.4 comment is empty 20.12.2021, 17:11:38 2 0.991 0.2 -0.053 -1.5 -0.120 0.0 -1.5 comment is empty 20.12.2021, 17:11:39 3 0.776 0.3 -0.516 -16.8 -0.363 0.0 -16.8 comment is empty 20.12.2021, 17:11:40 No Stokes Comp. 1 Lin. PER [dB] Stokes Comp. 2 φ [°] Stokes Comp. 3 Intensity [%] φ [°] Comment Timestamp 1 0.845 0.3 -0.525 -15.9 -0.100 0.0 -15.9 comment is empty 20.12.2021, 17:11:50 2 0.453 0.2 -0.683 -28.2 -0.573 0.0 -28.2 comment is empty 20.12.2021, 17:11:51 3 0.362 0.4 -0.876 -33.8 -0.320 0.0 -33.8 comment is empty 20.12.2021, 17:11:52 No Stokes Comp. 1 Lin. PER [dB] Stokes Comp. 2 φ [°] Stokes Comp. 3 Intensity [%] φ [°] Comment Timestamp 1 0.021 0.2 -0.640 -44.1 -0.768 0.0 -44.1 comment is empty 20.12.2021, 17:12:01 2 -0.930 0.1 -0.161 -85.1 -0.330 0.0 -85.1 comment is empty 20.12.2021, 17:12:02 3 -0.388 0.3 -0.805 -57.9 -0.450 0.0 -57.9 comment is empty 20.12.2021, 17:12:03 No Stokes Comp. 1 Lin. PER [dB] Stokes Comp. 2 φ [°] Stokes Comp. 3 Intensity [%] φ [°] Comment Timestamp 1 -0.725 0.2 -0.609 -70.0 0.322 0.0 -70.0 comment is empty 20.12.2021, 17:12:13 2 -0.198 0.1 0.376 58.9 -0.905 0.0 58.9 comment is empty 20.12.2021, 17:12:14 3 0.133 0.3 -0.938 -41.0 -0.320 0.0 -41.0 comment is empty 20.12.2021, 17:12:15 No Stokes Comp. 1 Lin. PER [dB] Stokes Comp. 2 φ [°] Stokes Comp. 3 Intensity [%] φ [°] Comment Timestamp 1 -0.305 0.1 -0.313 -67.1 -0.899 0.0 -67.1 comment is empty 20.12.2021, 17:12:24 2 -0.910 0.2 -0.026 -89.2 -0.414 0.0 -89.2 comment is empty 20.12.2021, 17:12:25 3 -0.452 0.3 -0.874 -58.7 -0.175 0.0 -58.7 comment is empty 20.12.2021, 17:12:26 No Stokes Comp. 1 Lin. PER [dB] Stokes Comp. 2 φ [°] Stokes Comp. 3 Intensity [%] φ [°] Comment Timestamp 1 0.732 0.3 0.584 19.3 0.350 0.0 19.3 comment is empty 20.12.2021, 17:12:35 2 -0.632 0.2 0.686 66.3 -0.359 0.0 66.3 comment is empty 20.12.2021, 17:12:36 3 -0.268 0.2 -0.387 -62.3 -0.882 0.0 -62.3 comment is empty 20.12.2021, 17:12:37 No Stokes Comp. 1 Lin. PER [dB] Stokes Comp. 2 φ [°] Stokes Comp. 3 Intensity [%] φ [°] Comment Timestamp 1 -0.462 0.1 -0.666 -62.4 -0.586 0.0 -62.4 comment is empty 20.12.2021, 17:12:47 2 0.260 0.3 -0.955 -37.4 -0.140 0.0 -37.4 comment is empty 20.12.2021, 17:12:48 3 -0.001 0.2 -0.966 -45.0 -0.260 0.0 -45.0 comment is empty 20.12.2021, 17:12:49 No Stokes Comp. 1 Lin. PER [dB] Stokes Comp. 2 φ [°] Stokes Comp. 3 Intensity [%] φ [°] Comment Timestamp 1 0.037 0.2 -0.844 -43.7 0.534 0.0 -43.7 comment is empty 20.12.2021, 17:12:58 2 -0.883 0.1 0.042 88.6 -0.467 0.0 88.6 comment is empty 20.12.2021, 17:12:59 3 -0.045 0.4 -0.991 -46.3 -0.122 0.0 -46.3 comment is empty 20.12.2021, 17:13:00 No Stokes Comp. 1 Lin. PER [dB] Stokes Comp. 2 φ [°] Stokes Comp. 3 Intensity [%] φ [°] Comment Timestamp 1 -0.915 0.3 -0.108 -86.6 -0.388 0.0 -86.6 comment is empty 20.12.2021, 17:13:10 2 -0.546 0.2 -0.834 -61.6 -0.079 0.0 -61.6 comment is empty 20.12.2021, 17:13:11 3 -0.287 0.2 -0.856 -54.3 0.430 0.0 -54.3 comment is empty 20.12.2021, 17:13:12 No Stokes Comp. 1 Lin. PER [dB] Stokes Comp. 2 φ [°] Stokes Comp. 3 Intensity [%] φ [°] Comment Timestamp 1 -0.673 0.1 -0.627 -68.5 0.393 0.0 -68.5 comment is empty 20.12.2021, 17:13:21 2 0.942 0.3 -0.300 -8.8 0.153 0.0 -8.8 comment is empty 20.12.2021, 17:13:22 3 -0.605 0.2 -0.640 -66.7 -0.475 0.0 -66.7 comment is empty 20.12.2021, 17:13:23 No Stokes Comp. 1 Lin. PER [dB] Stokes Comp. 2 φ [°] Stokes Comp. 3 Intensity [%] φ [°] Comment Timestamp 1 -0.993 0.4 -0.057 -88.4 0.104 0.0 -88.4 comment is empty 20.12.2021, 17:13:33 2 0.737 0.2 -0.319 -11.7 -0.596 0.0 -11.7 comment is empty 20.12.2021, 17:13:33 3 -0.738 0.2 0.229 81.4 -0.635 0.0 81.4 comment is empty 20.12.2021, 17:13:35 No Stokes Comp. 1 Lin. PER [dB] Stokes Comp. 2 φ [°] Stokes Comp. 3 Intensity [%] φ [°] Comment Timestamp 1 -0.475 0.1 0.643 63.2 -0.600 0.0 63.2 comment is empty 20.12.2021, 17:13:44 2 -0.151 0.3 -0.977 -49.4 -0.151 0.0 -49.4 comment is empty 20.12.2021, 17:13:45 3 -0.379 0.2 -0.661 -59.9 -0.648 0.0 -59.9 comment is empty 20.12.2021, 17:13:46 No Stokes Comp. 1 Lin. PER [dB] Stokes Comp. 2 φ [°] Stokes Comp. 3 Intensity [%] φ [°] Comment Timestamp 1 -0.307 0.3 -0.847 -55.0 -0.433 0.0 -55.0 comment is empty 20.12.2021, 17:13:55 2 -0.338 0.2 -0.764 -56.9 -0.550 0.0 -56.9 comment is empty 20.12.2021, 17:13:56 3 0.909 0.4 -0.303 -9.2 -0.288 0.0 -9.2 comment is empty 20.12.2021, 17:13:57 No Stokes Comp. 1 Lin. PER [dB] Stokes Comp. 2 φ [°] Stokes Comp. 3 Intensity [%] φ [°] Comment Timestamp 1 -0.476 0.3 -0.859 -59.5 -0.189 0.0 -59.5 comment is empty 20.12.2021, 17:14:07 2 -0.345 0.3 -0.907 -55.4 0.239 0.0 -55.4 comment is empty 20.12.2021, 17:14:08 3 0.655 0.3 -0.636 -22.1 -0.408 0.0 -22.1 comment is empty 20.12.2021, 17:14:09 No Stokes Comp. 1 Lin. PER [dB] Stokes Comp. 2 φ [°] Stokes Comp. 3 Intensity [%] φ [°] Comment Timestamp 1 0.343 0.2 -0.844 -34.0 -0.412 0.0 -34.0 comment is empty 20.12.2021, 17:14:18 2 0.398 0.3 -0.889 -32.9 -0.226 0.0 -32.9 comment is empty 20.12.2021, 17:14:19 3 -0.253 0.2 -0.837 -53.4 -0.486 0.0 -53.4 comment is empty 20.12.2021, 17:14:20 No Stokes Comp. 1 Lin. PER [dB] Stokes Comp. 2 φ [°] Stokes Comp. 3 Intensity [%] φ [°] Comment Timestamp 1 0.009 0.0 -0.012 -27.3 -1.000 0.0 -27.3 comment is empty 20.12.2021, 17:14:30 2 -0.881 0.2 -0.271 -81.5 -0.388 0.0 -81.5 comment is empty 20.12.2021, 17:14:31 3 -0.166 0.2 -0.963 -49.9 -0.212 0.0 -49.9 comment is empty 20.12.2021, 17:14:32 No Stokes Comp. 1 Lin. PER [dB] Stokes Comp. 2 φ [°] Stokes Comp. 3 Intensity [%] φ [°] Comment Timestamp 1 -0.435 0.2 -0.532 -64.6 -0.726 0.0 -64.6 comment is empty 20.12.2021, 17:14:41 2 -0.628 0.4 0.758 64.8 -0.177 0.0 64.8 comment is empty 20.12.2021, 17:14:42 3 0.810 0.3 -0.505 -16.0 -0.298 0.0 -16.0 comment is empty 20.12.2021, 17:14:43 No Stokes Comp. 1 Lin. PER [dB] Stokes Comp. 2 φ [°] Stokes Comp. 3 Intensity [%] φ [°] Comment Timestamp 1 0.515 0.1 -0.484 -21.6 -0.708 0.0 -21.6 comment is empty 20.12.2021, 17:14:53 2 0.652 0.1 0.229 9.7 0.723 0.0 9.7 comment is empty 20.12.2021, 17:14:54 3 0.993 0.2 -0.104 -3.0 0.058 0.0 -3.0 comment is empty 20.12.2021, 17:14:55 No Stokes Comp. 1 Lin. PER [dB] Stokes Comp. 2 φ [°] Stokes Comp. 3 Intensity [%] φ [°] Comment Timestamp 1 -0.315 0.1 -0.326 -67.0 -0.891 0.0 -67.0 comment is empty 20.12.2021, 17:15:04 2 -0.459 0.3 -0.827 -59.5 -0.325 0.0 -59.5 comment is empty 20.12.2021, 17:15:05 3 -0.581 0.1 0.260 78.0 -0.771 0.0 78.0 comment is empty 20.12.2021, 17:15:06 No Stokes Comp. 1 Lin. PER [dB] Stokes Comp. 2 φ [°] Stokes Comp. 3 Intensity [%] φ [°] Comment Timestamp 1 -0.650 0.3 -0.710 -66.2 -0.272 0.0 -66.2 comment is empty 20.12.2021, 17:15:15 2 -0.165 0.2 -0.898 -50.2 -0.409 0.0 -50.2 comment is empty 20.12.2021, 17:15:16 3 0.398 0.3 -0.915 -33.2 0.065 0.0 -33.2 comment is empty 20.12.2021, 17:15:17 No Stokes Comp. 1 Lin. PER [dB] Stokes Comp. 2 φ [°] Stokes Comp. 3 Intensity [%] φ [°] Comment Timestamp 1 0.895 0.3 -0.376 -11.4 -0.239 0.0 -11.4 comment is empty 20.12.2021, 17:15:27 2 -0.684 0.2 -0.519 -71.4 -0.513 0.0 -71.4 comment is empty 20.12.2021, 17:15:28 3 -0.475 0.2 -0.834 -59.8 0.279 0.0 -59.8 comment is empty 20.12.2021, 17:15:29 No Stokes Comp. 1 Lin. PER [dB] Stokes Comp. 2 φ [°] Stokes Comp. 3 Intensity [%] φ [°] Comment Timestamp 1 0.735 0.2 -0.269 -10.1 -0.622 0.0 -10.1 comment is empty 20.12.2021, 17:15:38 2 -0.258 0.1 -0.249 -68.0 -0.933 0.0 -68.0 comment is empty 20.12.2021, 17:15:39 3 -0.782 0.3 -0.377 -77.1 -0.496 0.0 -77.1 comment is empty 20.12.2021, 17:15:40 No Stokes Comp. 1 Lin. PER [dB] Stokes Comp. 2 φ [°] Stokes Comp. 3 Intensity [%] φ [°] Comment Timestamp 1 -0.776 0.2 0.320 78.8 -0.543 0.0 78.8 comment is empty 20.12.2021, 17:15:50 2 0.364 0.2 -0.853 -33.4 -0.374 0.0 -33.4 comment is empty 20.12.2021, 17:15:51 3 -0.923 0.2 -0.241 -82.7 -0.301 0.0 -82.7 comment is empty 20.12.2021, 17:15:52 No Stokes Comp. 1 Lin. PER [dB] Stokes Comp. 2 φ [°] Stokes Comp. 3 Intensity [%] φ [°] Comment Timestamp 1 0.700 0.4 -0.690 -22.3 -0.185 0.0 -22.3 comment is empty 20.12.2021, 17:16:01 2 -0.225 0.3 -0.855 -52.4 0.468 0.0 -52.4 comment is empty 20.12.2021, 17:16:02 3 -0.474 0.4 -0.875 -59.2 -0.098 0.0 -59.2 comment is empty 20.12.2021, 17:16:03 No Stokes Comp. 1 Lin. PER [dB] Stokes Comp. 2 φ [°] Stokes Comp. 3 Intensity [%] φ [°] Comment Timestamp 1 0.889 0.1 -0.028 -0.9 -0.456 0.0 -0.9 comment is empty 20.12.2021, 17:16:13 2 0.637 0.1 -0.543 -20.2 -0.548 0.0 -20.2 comment is empty 20.12.2021, 17:16:14 3 0.081 0.2 -0.982 -42.7 -0.168 0.0 -42.7 comment is empty 20.12.2021, 17:16:15 No Stokes Comp. 1 Lin. PER [dB] Stokes Comp. 2 φ [°] Stokes Comp. 3 Intensity [%] φ [°] Comment Timestamp 1 0.650 0.2 -0.662 -22.8 0.375 0.0 -22.8 comment is empty 20.12.2021, 17:16:24 2 -0.121 0.2 0.831 49.1 -0.544 0.0 49.1 comment is empty 20.12.2021, 17:16:25 3 -0.422 0.1 -0.731 -60.0 -0.537 0.0 -60.0 comment is empty 20.12.2021, 17:16:26 No Stokes Comp. 1 Lin. PER [dB] Stokes Comp. 2 φ [°] Stokes Comp. 3 Intensity [%] φ [°] Comment Timestamp 1 -0.060 0.2 -0.896 -46.9 -0.441 0.0 -46.9 comment is empty 20.12.2021, 17:16:35 2 0.837 0.2 0.407 12.9 -0.365 0.0 12.9 comment is empty 20.12.2021, 17:16:36 3 -0.100 0.2 -0.986 -47.9 -0.134 0.0 -47.9 comment is empty 20.12.2021, 17:16:37 No Stokes Comp. 1 Lin. PER [dB] Stokes Comp. 2 φ [°] Stokes Comp. 3 Intensity [%] φ [°] Comment Timestamp 1 -0.591 0.3 -0.792 -63.4 0.151 0.0 -63.4 comment is empty 20.12.2021, 17:16:47 2 0.761 0.1 0.055 2.1 -0.647 0.0 2.1 comment is empty 20.12.2021, 17:16:48 3 -0.411 0.3 -0.741 -59.5 -0.530 0.0 -59.5 comment is empty 20.12.2021, 17:16:49'; preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0); // Print the entire match result var_dump($matches);

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 PHP, please visit: http://php.net/manual/en/ref.pcre.php