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

$re = '/([\d.-]+),(\d[\d.]+|(?:.)[-\d.]+)/m'; $str = 'Latitude/Longitude #Н/Д 33.651272, -117.990384 49.996387, 8.281494 46.214978, -74.584957 32.681523, -117.177851 33.56666, -111.918578 15.30686, 73.911334 #Н/Д 19.762559, -70.641425 38.427717, 27.135626 1.306349, 103.833247 45.507321, -73.565433 42.349027, -71.076333 29.461875, -98.681267 37.933797, -107.851831 18.797263, 98.969404 #Н/Д 25.216342, 55.251621 #Н/Д 47.497362, 19.052305 51.499288, -0.157697 39.949119, -75.164844 #Н/Д 32.710152, -117.168404 #Н/Д 49.283749, -123.120783 28.427015, -81.467563 24.547717, -81.794206 31.777066, 35.222551 36.991932, 27.510750 #Н/Д 38.126632, 13.350806 46.438612, 6.906799 40.42222, -3.684213 45.43074, 12.33365 #Н/Д 43.748048, 7.438787 #Н/Д 40.75802, -73.974978 40.55092, 14.247042 45.501572, -73.577923 29.954252, -90.067597 37.937361, -107.846632 #Н/Д #Н/Д 41.884363, -87.620725 42.35773, -71.06013 33.845612, -84.370387 29.955761, -90.067887 38.562024, -76.048393 38.29757, -122.289269 40.752888, -73.981033 47.610043, -122.335561 33.64516, -111.917536 32.848638, -117.273695 #Н/Д #Н/Д 53.334528, -6.258232 51.494308, -0.175558 1.29343, 103.858809 18.698384, -68.451145 43.292645, 5.359823 59.331914, 18.080605 40.414559, -3.701406 #Н/Д 10.641584, -85.658913 #Н/Д 45.51986, -122.677339 33.720253, -116.331044 39.184541, -106.814381 #Н/Д #Н/Д 48.870763, 2.32976 #Н/Д 19.427554, -99.192761 20.912971, -156.692167 -36.844873, 174.757413 #Н/Д 14.550757, 121.023001 52.351381, 4.872723 #Н/Д #Н/Д 46.507219, 6.628285 50.091392, 14.418329 #Н/Д #Н/Д -23.616574, -46.698208 34.988825, 135.773575 48.875029, 2.301244 48.204556, 16.356343 41.061244, 28.989182 36.152536, -86.78409 52.508285, 13.372674 37.782208, -122.404827 47.623197, -70.143448 30.26815, -97.741755 #Н/Д 44.975925, -93.268833 45.42487, -75.694846 24.90005, -80.655148 45.500618, -73.567779 32.25354, -64.826465 45.4288, -75.6909 45.754784, 4.834093 43.165676, -73.070642 25.760484, -80.190906 39.639253, -106.36816 41.901359, -87.627417 48.139461, 11.556781 45.5175, -122.680077 #Н/Д 51.507894, -0.143671 41.881643, -87.625001 #Н/Д 43.586675, -110.829048 39.199682, -120.21733 #Н/Д 42.357306, -71.060687 52.367811, 4.883059 22.902842, -109.893796 #Н/Д 51.216544, 6.752721 #Н/Д 25.112432, 55.138978 22.297617, 114.173412 #Н/Д #Н/Д 50.94043, 6.96953 45.434116, 12.345296 #Н/Д 50.460406, 30.525621 30.071856, 31.227775 33.688495, -116.310231 40.441484, -80.001392 45.502202, -73.575932 33.092115, -117.266082 40.76821, -73.984871 -17.485714, -149.844102 45.645307, -74.949563 52.512172, 13.392269 #Н/Д 51.49732, -0.156256 39.94934, -75.148884 30.16498, -97.447389 32.786262, -96.802363 30.247365, -97.750116 20.464019, -86.98145 32.080843, -81.093186 40.757794, -73.983784 19.367662, -99.261276 -8.491628, 115.253863 #Н/Д #Н/Д 43.740065, 7.429895 #Н/Д 42.862323, 11.877213 41.907613, 12.486654 55.733426, 37.643884 #Н/Д #Н/Д 43.645957, -79.381225 48.868479, 2.32696 39.956932, -75.170271 45.520565, -122.682308 43.567281, -70.227882 43.298433, 5.370189 #Н/Д #Н/Д 51.499391, -0.132902 37.859041, -122.242507 50.087629, 14.418374 #Н/Д 21.278263, -157.830944 39.996165, -78.506873 34.059998, -118.437348 39.747902, -104.992659 33.80088, -117.917943 #Н/Д 20.00622, -155.824418 45.686618, -121.904606 51.515227, -0.15689 #Н/Д 41.901996, 12.496173 48.871137, 2.305048 #Н/Д 21.049951, 105.839836 #Н/Д 48.86731, 2.285653 11.546306, 104.933521 -31.960749, 115.873621 52.502489, 13.331838 #Н/Д 31.955839, 35.909983 48.868414, 2.321325 #Н/Д 51.526777, -0.132491 #Н/Д 45.427556, 12.319975 #Н/Д #Н/Д 10.426671, -75.551485 #Н/Д 43.683912, 7.234447 40.722705, -74.004755 #Н/Д 4.670009, -74.053064 20.701884, -103.376744 41.898711, -87.627507 59.330871, 18.07692 39.289747, -76.615713 42.648166, 11.512796 41.880875, -87.631752 #Н/Д 18.358936, -65.627641 41.891105, -87.627045 #Н/Д 41.919833, 12.48141 -34.890494, -56.055399 40.719796, -74.000036 #Н/Д 34.076409, -118.377376 18.358936, -65.627641 47.606956, -122.334083 #Н/Д 43.775288, 11.268054 48.877209, 2.296827 50.114976, 8.680725 48.875689, 2.325465 #Н/Д 48.213049, 16.37988 38.905748, -77.051673 41.89775, 12.477402 -12.097482, -77.038037 41.047295, 29.009608 32.782866, -79.932486 38.863056, -77.060109 #Н/Д 25.80611, -80.123885 25.817853, -80.122189 33.65815, -118.002853 43.649088, -79.376254 29.891735, -81.313635 25.925468, -81.728497 32.067345, -81.094695 35.566771, -82.543989 #Н/Д 40.758564, -73.989752 37.785151, -122.405832 27.973556, -82.828887 25.082129, -77.313443 #Н/Д 39.604113, -106.518129 28.403354, -81.527306 33.018943, -117.205013 21.135079, -86.754185 38.312007, -122.482274 7.977468, 98.280525 #Н/Д #Н/Д 32.078956, -81.084662 #Н/Д #Н/Д 35.681788, 139.766761 #Н/Д -37.81482, 144.969433 -6.192999, 106.822267 #Н/Д 51.507796, -0.132736 38.895247, -77.010755 #Н/Д 30.259891, -97.739039 21.799584, -72.169424 35.68849, -105.94199 32.716214, -117.159884 37.786773, -122.411287 25.792099, -80.129032 25.082129, -77.313443 40.715002, -74.015222 33.529497, -111.9731 34.054158, -118.412522 #Н/Д 35.67413, 139.741144 22.293418, 114.1741 8.086453, 98.298955 -33.871776, 151.207517 19.424141, -99.164983 37.56499, 126.981369 39.905531, 116.452054 #Н/Д 41.907184, 12.465629 41.910272, 12.490268 45.435363, 12.33034 43.48799, -1.554047 43.552132, 7.020803 43.770168, 11.254647 51.504939, -0.150134 40.632959, 14.597304 45.463074, 9.197959 18.443791, -66.017754 53.339403, -6.26142 #Н/Д #Н/Д #Н/Д #Н/Д #Н/Д 20.627574, -87.071673 13.738771, 100.546892 24.498927, 54.367727 10.784333, 106.70233 51.508404, -0.106799 34.869604, -111.758506 25.06669, -80.472195 16.826175, -99.862064 40.764524, -73.978457 #Н/Д 32.358914, -111.025531 47.604883, -122.336772 33.447461, -112.073668 #Н/Д 41.042358, 28.997222 13.720597, 100.521526 -33.92169, 18.41503 40.632061, 14.388932 45.466812, 9.19417 32.08917, 34.770897 27.969708, -82.830149 #Н/Д 40.759394, -73.97491 #Н/Д 41.883627, 8.783506 37.854097, 15.287703 #Н/Д 39.950948, -75.169541 41.894755, -87.624649 32.801184, -79.753959 #Н/Д 29.741522, -95.457223 #Н/Д 51.517992, -0.149945 #Н/Д #Н/Д #Н/Д 29.956285, -90.065736 48.201709, 16.37102 #Н/Д 15.458414, 73.834555 #Н/Д 27.655985, -80.356579 38.726695, -9.155536 39.767605, -86.159359 34.100633, -118.342451 34.018671, -118.501103 #Н/Д 33.426067, -111.93888 40.413861, -3.701654 37.443679, -122.161438 25.78198, -80.142873 43.775408, 11.236838 29.768061, -95.459858 34.094441, -118.374329 #Н/Д -8.780949, 115.225344 #Н/Д 41.389465, 2.166265 43.503149, 16.466029 #Н/Д 43.264851, -2.944282 49.360028, 0.071022 #Н/Д #Н/Д 42.69499, 18.015217 25.991705, -80.118572 #Н/Д #Н/Д 1.279973, 103.849728 13.043045, 80.248685 40.757524, -73.984059 40.682436, -111.556877 #Н/Д #Н/Д #Н/Д 40.719404, -74.004902 49.28794, -123.113052 43.473395, -110.757499 #Н/Д -33.868221, 151.195376 41.880283, -87.626698 13.719827, 100.524582 31.235252, 121.505749 35.66823, 139.741089 13.373635, 103.860755 51.509918, -0.155092 41.905609, 12.481517 49.359441, 0.068769 7.809057, 98.407633 43.548459, 7.011745 52.372646, 4.894815 24.414582, 54.490653 56.320216, -2.730864 20.631616, -87.067938 47.612364, -122.352234 #Н/Д #Н/Д #Н/Д #Н/Д 25.771157, -80.189093 40.722146, -74.004627 34.420361, -119.702475 #Н/Д #Н/Д 41.030366, 28.97213 #Н/Д 46.203376, 6.152146 38.305045, -122.283122 47.656935, -122.207112 13.734435, 100.564074 #Н/Д 40.397731, 116.685866 50.086448, 14.433853 41.023608, 28.975579 23.116958, 113.330099 #Н/Д #Н/Д #Н/Д #Н/Д 36.157258, -86.784757 22.889828, -109.906413 #Н/Д #Н/Д #Н/Д 37.959827, 23.721196 -37.814119, 144.972841 -28.029305, 153.432039 #Н/Д 40.436341, -3.690219 25.084986, -77.327843 #Н/Д #Н/Д #Н/Д #Н/Д 40.764796, -111.89171 33.845336, -118.39689 #Н/Д 22.898715, -109.869525 35.627764, 139.740875 #Н/Д 29.610563, -98.606705 #Н/Д 33.803185, -111.926368 41.886398, -87.620373 19.92547, -155.888329 -37.824004, 144.957279 47.610573, -122.341351 -31.963829, 115.895371 38.721, -9.146966 9.8547, -85.401159 41.893896, -87.625155 28.467883, -81.467381 39.504098, 2.532353 50.117189, 8.687097 #Н/Д -6.235031, 106.830287 #Н/Д 48.844908, 2.252661 #Н/Д 51.511719, -0.11832 41.406146, 2.200864 43.874187, -121.446471 #Н/Д 20.627574, -87.071673 14.574209, 120.988054 26.508515, 127.857330 #Н/Д #Н/Д 45.479385, 9.196131 -18.108194, 177.32183 45.446452, 12.331218 25.770522, -80.189339 -8.791699, 115.229904 -8.799112, 115.2319 -6.225909, 106.798943 31.245349, 121.493066 43.560583, 39.77537 #Н/Д 32.709513, -117.232061 64.139838, -21.888807 36.12269, -115.170194 31.221819, 121.475592 53.549723, 9.988088 25.059742, 55.127965 #Н/Д 28.465954, -81.469608 -8.706277, 115.261997 39.908628, 116.417694 #Н/Д 50.83615, 4.357117 46.574756, 11.671541 -22.985935, -43.207361 32.775196, -96.804121 #Н/Д 41.906055, -87.628471 25.125078, 55.113931 26.154067, -80.100589 39.203812, -106.95979 41.408452, 2.217902 #Н/Д #Н/Д #Н/Д #Н/Д 32.836131, -96.778019 37.807486, -122.42046 #Н/Д 31.387605, 120.948235 53.54026, -113.489494 #Н/Д 64.146367, -21.930777 26.703167, -80.0407 #Н/Д 27.709328, -82.737269 #Н/Д 40.766017, -73.978641 30.554897, -81.444502 #Н/Д #Н/Д 31.269896, 121.587441 36.107349, -115.176584 -1.521942, 35.336838 39.927602, -105.118404 36.157262, -86.775414 #Н/Д 43.567889, 7.114898 29.423081, -98.489885 30.254173, 120.161609 36.090861, -115.175027 33.742683, -116.405986 30.291154, -97.858809 #Н/Д 39.927215, 116.460478 36.102251, -115.169968 36.120611, -115.176839 #Н/Д #Н/Д #Н/Д 21.703253, -157.996841 -31.958793, 115.868521 1.292305, 103.858594 25.789019, -80.129468 #Н/Д 31.628794, -7.99668 #Н/Д 19.065452, 72.864425 #Н/Д #Н/Д 36.150776, -86.802207 -1.277851, 36.815342 #Н/Д #Н/Д 37.546436, -77.444152 34.103081, -118.339326 #Н/Д 42.349194, -71.072526 44.257279, -71.439481 34.202407, 108.988552 34.008974, -118.492874 29.947995, -90.066145 44.97891, -93.275052 #Н/Д #Н/Д #Н/Д 26.051377, -80.211226 32.63125, -117.135418 #Н/Д 39.951743, -75.160204 27.992844, -82.372114 #Н/Д #Н/Д 38.979419, -76.505803 #Н/Д #Н/Д #Н/Д #Н/Д '; 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