Regular Expressions 101

Save & Share

  • Regex Version: ver. 21
  • 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

/
/
gm

Test String

Substitution

Processing...

Code Generator

Generated Code

$re = '/ 0 = "TLS/m'; $str = 'MTM278 Test Data File Output file name: D:\\2021\\CRODA-V03\\VP1-1334-42-01\\KO_00079_2021\\KO_00079_2021-1.mtmd Profile file name: D:\\2020\\01_Methoden\\Croda_V03a.mtmp Profile description: Croda-V03a Lubricant name: Comments: Number of steps in profile: 12 Number of steps completed: 12 Test started at 09.02.2021 12:06:13 Step 1 started at 09.02.2021 12:16:22 Step type Traction Step description SRR 1 -100%. 30N. 40C Zero traction force (N) 0.9055 (measured at the start of this step) Disc track radius used for this step (mm) 21.078 SRR (%) Traction Coeff (-) Step Time (s) Pot RTD Temp (degC) Lube RTD Temp (degC) Ball Load (N) Pin Load (N) Wear (um) ECR (%) Ball Speed 1 Ball Speed 2 Ball Speed 3 Ball Speed 4 Disc Speed 1 Disc Speed 2 Disc Speed 3 Disc Speed 4 Disc Frequency (Hz) Rolling Speed (mm/s) Sliding Speed (mm/s) SRR (%) TF1 (N) TF2 (N) TF3 (N) TF4 (N) Traction Force (N) Traction Coeff (-) Rolling Force (N) Rolling Coeff (-) Traction Trace (-) 1.003 0.0022 6 39.7 40.1 29.868 341 0 1990.03 2009.93 2009.74 1989.53 1999.81 20.05 1.003 1.0718 0.9433 0.0643 0.0022 1.993 0.0041 12 39.6 40.1 29.989 337 0 1979.91 2019.36 2020.27 1980.02 1999.89 39.85 1.993 1.1262 0.8794 0.1234 0.0041 3.011 0.0060 18 39.6 40.0 29.866 349 0 1969.89 2030.23 2030.18 1970.07 2000.09 60.22 3.011 1.1759 0.8182 0.1789 0.0060 3.997 0.0075 24 39.5 39.9 29.825 340 0 1959.39 2039.68 2039.81 1960.23 1999.78 79.94 3.997 1.2227 0.7727 0.2250 0.0075 5.007 0.0089 31 39.5 39.9 29.883 340 0 1949.92 2050.08 2049.91 1949.80 1999.93 100.14 5.007 1.2621 0.7277 0.2672 0.0089 5.995 0.0100 37 39.4 39.8 30.183 345 0 1940.03 2059.90 2059.92 1939.99 1999.96 119.90 5.995 1.2893 0.6864 0.3014 0.0100 7.004 0.0112 43 39.4 39.8 30.040 343 0 1930.07 2069.98 2070.03 1929.77 1999.96 140.08 7.004 1.3306 0.6579 0.3363 0.0112 8.013 0.0121 49 39.4 39.8 29.930 340 0 1919.87 2079.99 2080.43 1920.00 2000.07 160.27 8.013 1.3542 0.6318 0.3612 0.0121 8.999 0.0131 55 39.4 39.8 29.792 346 0 1909.95 2090.09 2089.96 1910.16 2000.04 179.97 8.999 1.3800 0.6019 0.3891 0.0131 9.986 0.0138 61 39.3 39.8 29.963 340 0 1899.96 2099.58 2099.72 1899.93 1999.80 199.70 9.986 1.4048 0.5766 0.4141 0.0138 14.988 0.0168 67 39.3 39.8 29.899 340 0 1849.98 2149.82 2149.90 1850.25 1999.99 299.75 14.988 1.4914 0.4873 0.5020 0.0168 19.987 0.0189 74 39.3 39.8 29.819 343 0 1800.03 2199.72 2199.95 1800.19 1999.97 399.73 19.987 1.5496 0.4232 0.5632 0.0189 24.988 0.0203 80 39.3 39.8 30.175 343 0 1750.03 2249.85 2250.04 1750.30 2000.06 499.78 24.988 1.6014 0.3749 0.6133 0.0203 29.989 0.0215 86 39.4 39.8 30.033 339 0 1699.95 2299.98 2299.84 1700.31 2000.02 599.78 29.989 1.6315 0.3411 0.6452 0.0215 34.995 0.0224 92 39.4 39.8 30.094 344 0 1649.95 2349.96 2349.98 1650.16 2000.01 699.91 34.995 1.6605 0.3144 0.6731 0.0224 39.988 0.0231 98 39.4 39.9 30.139 345 0 1600.13 2399.55 2400.45 1600.27 2000.10 799.80 39.988 1.6827 0.2875 0.6976 0.0231 44.971 0.0234 104 39.4 39.9 30.264 347 0 1550.32 2449.55 2449.76 1550.21 1999.96 899.39 44.971 1.6931 0.2738 0.7097 0.0234 49.981 0.0238 110 39.5 39.9 30.274 348 0 1500.15 2499.81 2499.47 1500.04 1999.87 999.55 49.981 1.7076 0.2638 0.7219 0.0238 59.980 0.0244 116 39.5 39.9 30.251 344 0 1400.08 2599.53 2600.19 1400.37 2000.04 1199.63 59.980 1.7231 0.2495 0.7368 0.0244 69.970 0.0250 123 39.5 39.9 29.870 348 0 1300.10 2699.37 2699.42 1300.21 1999.78 1399.24 69.970 1.7331 0.2418 0.7456 0.0250 79.960 0.0251 129 39.5 40.0 29.997 344 0 1200.34 2799.44 2799.70 1200.42 1999.97 1599.19 79.960 1.7423 0.2347 0.7538 0.0251 89.981 0.0250 135 39.5 40.0 30.032 348 0 1100.22 2898.95 2899.92 1099.88 1999.74 1799.39 89.981 1.7338 0.2332 0.7503 0.0250 99.959 0.0250 141 39.5 40.1 29.651 336 0 1000.47 2998.83 2999.35 1000.02 1999.67 1998.85 99.959 1.7360 0.2542 0.7409 0.0250 Step 2 started at 09.02.2021 12:18:53 Step type Stribeck Step description 50% SRR. 30N. 0-3.2m/s. 40C Zero traction force (N) 0.7063 (measured at the start of this step) Disc track radius used for this step (mm) 21.078 Rolling Speed (mm/s) Traction Coeff (-) Step Time (s) Pot RTD Temp (degC) Lube RTD Temp (degC) Ball Load (N) Pin Load (N) Wear (um) ECR (%) Ball Speed 1 Ball Speed 2 Ball Speed 3 Ball Speed 4 Disc Speed 1 Disc Speed 2 Disc Speed 3 Disc Speed 4 Disc Frequency (Hz) Rolling Speed (mm/s) Sliding Speed (mm/s) SRR (%) TF1 (N) TF2 (N) TF3 (N) TF4 (N) Traction Force (N) Traction Coeff (-) Rolling Force (N) Rolling Coeff (-) Traction Trace (-) 3199.615 0.0231 6 39.4 40.1 29.986 341 0 2400.32 3998.23 3999.27 2400.64 3199.62 1598.27 49.952 1.6923 0.3072 0.6925 0.0231 2999.596 0.0231 12 39.4 40.1 29.980 335 0 2250.96 3748.61 3748.57 2250.24 2999.60 1497.99 49.940 1.6982 0.3154 0.6914 0.0231 2799.767 0.0233 19 39.5 40.1 29.971 341 0 2101.02 3498.66 3498.66 2100.73 2799.77 1397.79 49.925 1.7011 0.3028 0.6991 0.0233 2599.883 0.0236 25 39.5 40.1 30.035 338 0 1950.80 3249.04 3249.38 1950.31 2599.88 1298.66 49.951 1.7147 0.2943 0.7102 0.0236 2400.112 0.0237 31 39.5 40.1 30.152 340 0 1800.47 2999.85 2999.35 1800.77 2400.11 1198.98 49.955 1.7237 0.2949 0.7144 0.0237 2199.981 0.0235 37 39.5 40.1 30.367 344 0 1650.67 2749.30 2749.20 1650.75 2199.98 1098.55 49.934 1.7223 0.2949 0.7137 0.0235 1999.952 0.0240 43 39.5 40.1 30.039 339 0 1500.28 2499.60 2499.89 1500.04 1999.95 999.58 49.980 1.7347 0.2927 0.7210 0.0240 1799.939 0.0244 49 39.5 40.1 29.957 341 0 1350.36 2249.48 2249.66 1350.27 1799.94 899.26 49.960 1.7377 0.2744 0.7316 0.0244 1600.039 0.0246 55 39.5 40.1 29.912 344 0 1200.13 1999.93 1999.68 1200.42 1600.04 799.53 49.969 1.7471 0.2780 0.7346 0.0246 1399.978 0.0249 62 39.5 40.1 29.742 352 0 1050.10 1749.75 1749.97 1050.08 1399.98 699.77 49.984 1.7519 0.2735 0.7392 0.0249 1199.915 0.0248 68 39.4 40.1 30.084 343 0 900.09 1499.87 1499.68 900.02 1199.91 599.72 49.980 1.7618 0.2714 0.7452 0.0248 999.852 0.0253 74 39.4 40.0 29.779 350 0 750.00 1249.89 1249.73 749.78 999.85 499.92 50.000 1.7753 0.2674 0.7539 0.0253 900.136 0.0251 80 39.4 40.0 30.001 347 0 675.18 1125.02 1124.89 675.46 900.14 449.64 49.952 1.7675 0.2616 0.7530 0.0251 800.090 0.0254 86 39.3 40.0 29.889 345 0 599.96 1000.19 1000.46 599.75 800.09 400.47 50.054 1.7728 0.2567 0.7580 0.0254 699.932 0.0254 92 39.2 40.0 29.916 341 0 525.03 874.95 875.05 524.70 699.93 350.13 50.024 1.7761 0.2562 0.7600 0.0254 600.430 0.0257 98 39.2 40.0 29.903 341 0 449.97 750.07 750.32 451.36 600.43 299.53 49.887 1.7820 0.2458 0.7681 0.0257 500.151 0.0259 105 39.2 40.0 30.017 343 0 375.21 624.86 624.89 375.64 500.15 249.45 49.875 1.7906 0.2368 0.7769 0.0259 399.773 0.0266 111 39.2 40.0 29.754 345 0 299.78 500.02 499.28 300.02 399.77 199.75 49.966 1.8065 0.2236 0.7914 0.0266 300.018 0.0274 117 39.2 40.0 29.862 343 0 225.11 374.50 375.03 225.44 300.02 149.49 49.827 1.8310 0.1950 0.8180 0.0274 199.797 0.0293 123 39.1 40.0 30.073 343 0 149.83 249.93 249.05 150.38 199.80 99.39 49.743 1.8970 0.1325 0.8823 0.0293 99.510 0.0352 129 39.1 40.0 29.925 342 0 74.54 124.91 123.87 74.72 99.51 49.76 50.006 2.0885 -0.0206 1.0546 0.0352 90.435 0.0356 136 39.1 40.0 30.046 346 0 67.14 112.23 113.52 68.86 90.44 44.88 49.622 2.0952 -0.0431 1.0691 0.0356 80.236 0.0379 142 39.1 40.0 29.915 347 0 59.58 100.48 100.85 60.04 80.24 40.86 50.927 2.1687 -0.1010 1.1348 0.0379 70.010 0.0388 148 39.1 40.0 30.108 343 0 52.41 87.50 88.12 52.01 70.01 35.60 50.847 2.2000 -0.1360 1.1680 0.0388 59.811 0.0418 154 39.1 40.1 29.803 345 0 44.94 74.85 73.97 45.48 59.81 29.20 48.815 2.2755 -0.2136 1.2446 0.0418 50.163 0.0448 160 39.0 40.0 29.796 346 0 37.65 63.21 62.45 37.34 50.16 25.34 50.513 2.3836 -0.2859 1.3348 0.0448 39.954 0.0473 167 39.0 40.0 29.997 347 0 29.87 50.09 50.22 29.64 39.95 20.41 51.072 2.4243 -0.4126 1.4184 0.0473 30.028 0.0531 173 39.0 40.0 29.941 348 0 22.79 36.91 37.96 22.45 30.03 14.82 49.350 2.6702 -0.5088 1.5895 0.0531 20.068 0.0584 179 38.9 40.0 30.119 346 0 15.08 25.22 25.02 14.95 20.07 10.10 50.329 2.9042 -0.6132 1.7587 0.0584 9.649 0.0724 186 38.9 40.0 29.941 347 0 7.68 12.53 12.06 6.33 9.65 5.30 54.879 3.3080 -1.0265 2.1672 0.0724 7.050 0.0769 192 38.9 39.9 29.523 348 0 5.16 8.62 8.71 5.71 7.05 3.23 45.813 3.4929 -1.0454 2.2692 0.0769 3.892 0.0888 198 38.8 39.9 29.965 347 0 2.89 4.67 5.09 2.93 3.89 1.97 50.673 3.7258 -1.5974 2.6616 0.0888 1.001 0.0199 205 38.8 39.9 30.077 344 0 0.30 1.02 1.72 0.96 1.00 0.73 73.421 4.0679 2.8733 0.5973 0.0199 '; $subst = " \"TLS"; $result = preg_replace($re, $subst, $str); echo "The result of the substitution is ".$result;

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