Regular Expressions 101

Save & Share

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

/
/
g

Test String

Code Generator

Generated Code

$re = '/(\[\[-?[\d.,]+\](?:,\[-?[\d.,]+\])+\])/'; $str = '{"lines":[[[24,16.8],[24,15.8],[25,14.8],[26,14.8],[27,14.8],[27,13.8],[28,13.8],[29,13.8],[30,13.8],[32,13.8],[35,14.8],[44,16.8],[53,18.8],[63,21.8],[74,23.8],[87,28.8],[93,31.8],[100,33.8],[102,35.8],[104,36.8],[105,38.8],[108,42.8],[108,46.8],[108,48.8],[109,55.8],[109,57.8],[110,59.8],[110,66.8],[110,68.8],[110,73.8],[110,74.8],[109,77.8],[107,78.8],[106,80.8],[104,82.8],[102,84.8],[100,85.8],[96,87.8],[94,87.8],[92,88.8],[89,88.8],[87,88.8],[84,88.8],[81,88.8],[79,88.8],[77,88.8],[76,88.8],[74,87.8],[74,86.8],[70,85.8],[69,84.8],[67,82.8],[64,80.8],[64,78.8],[63,77.8],[62,76.8],[62,74.8],[62,73.8],[62,72.8],[62,71.8],[63,71.8],[63,70.8],[65,70.8],[66,69.8],[68,69.8],[70,69.8],[74,69.8],[81,69.8],[90,69.8],[101,69.8],[114,69.8],[116,69.8],[125,69.8],[130,69.8],[135,69.8],[138,69.8],[140,69.8],[149,69.8],[156,70.8],[164,70.8],[170,70.8],[177,70.8],[179,70.8],[184,71.8],[186,71.8],[187,70.8],[187,69.8],[187,66.8],[187,65.8],[187,63.8],[187,60.8],[187,55.8],[187,53.8],[187,47.8],[187,44.8],[187,43.8],[187,40.8],[186,39.8],[183,37.8],[181,35.8],[180,35.8],[179,34.8],[178,34.8],[177,34.8],[176,34.8],[174,34.8],[173,34.8],[171,35.8],[170,37.8],[169,37.8],[166,45.8],[165,48.8],[163,57.8],[161,59.8],[161,62.8],[160,64.8],[159,70.8],[159,73.8],[159,75.8],[159,77.8],[160,80.8],[161,82.8],[163,83.8],[164,85.8],[166,86.8],[168,86.8],[169,86.8],[170,87.8],[174,88.8],[175,88.8],[176,88.8],[178,88.8],[180,88.8],[182,89.8],[185,90.8],[190,91.8],[195,91.8],[198,91.8],[200,91.8],[202,91.8],[203,90.8],[205,89.8],[206,87.8],[207,81.8],[210,78.8],[212,75.8],[213,66.8],[215,62.8],[216,60.8],[217,58.8],[218,55.8],[219,53.8],[219,52.8],[219,50.8],[219,49.8],[219,48.8],[219,47.8],[218,47.8],[217,46.8],[216,46.8],[215,46.8],[214,46.8],[212,47.8],[211,48.8],[209,50.8],[207,57.8],[207,61.8],[205,67.8],[204,74.8],[204,78.8],[204,88.8],[204,95.8],[204,99.8],[204,102.8],[206,108.8],[208,110.8],[209,113.8],[210,116.8],[211,117.8],[211,119.8],[211,121.8],[211,122.8],[209,123.8],[208,125.8],[206,126.8],[203,127.8],[198,129.8],[196,130.8],[186,131.8],[178,131.8],[164,131.8],[153,132.8],[149,132.8],[143,132.8],[142,131.8],[140,131.8],[138,130.8],[137,128.8],[135,127.8],[135,126.8],[135,125.8],[135,124.8],[135,122.8],[135,121.8],[135,120.8],[136,119.8],[137,119.8],[138,119.8],[143,119.8],[151,119.8],[155,121.8],[172,122.8],[187,123.8],[199,124.8],[213,124.8],[224,124.8],[236,124.8],[246,124.8],[256,124.8],[261,124.8],[263,124.8],[264,124.8],[267,123.8],[268,121.8],[268,115.8],[268,111.8],[269,105.8],[269,98.8],[269,86.8],[269,80.8],[269,70.8],[269,67.8],[269,65.8],[267,62.8],[266,60.8],[264,59.8],[263,57.8],[262,57.8],[260,57.8],[259,57.8],[258,57.8],[257,58.8],[256,60.8],[255,61.8],[255,68.8],[253,72.8],[253,82.8],[252,93.8],[252,97.8],[252,103.8],[253,110.8],[255,111.8],[255,114.8],[258,115.8],[259,116.8],[260,117.8],[262,117.8],[264,117.8],[265,117.8],[266,117.8],[267,117.8],[268,117.8],[269,116.8],[271,115.8],[273,113.8],[274,111.8],[276,104.8],[278,100.8],[278,90.8],[278,75.8],[278,67.8],[278,65.8],[278,62.8],[278,60.8],[278,58.8],[277,58.8],[276,57.8],[275,56.8],[273,57.8],[272,59.8],[269,60.8],[269,65.8],[267,71.8],[265,78.8],[262,90.8],[260,104.8],[256,120.8],[254,132.8],[253,146.8],[252,161.8],[251,169.8],[250,175.8],[250,186.8],[250,188.8],[249,193.8],[248,195.8],[248,197.8],[247,199.8],[246,199.8],[243,199.8],[240,199.8],[232,198.8],[225,197.8],[216,195.8],[199,192.8],[178,190.8],[161,184.8],[147,182.8],[132,181.8],[131,181.8],[129,181.8],[129,180.8],[130,180.8],[130,179.8],[130,178.8],[130,177.8],[131,177.8],[131,176.8]], [[55,52.8],[57,52.8],[66,52.8],[74,52.8],[103,52.8],[128,52.8],[159,52.8],[198,52.8],[223,52.8],[238,52.8],[240,53.8],[250,59.8],[252,61.8],[253,63.8],[254,68.8],[254,79.8],[254,87.8],[254,97.8],[254,112.8],[254,120.8],[249,134.8],[247,145.8],[241,148.8],[234,151.8],[229,153.8],[223,156.8],[220,156.8],[213,156.8],[207,156.8],[200,155.8],[191,153.8],[185,148.8],[178,145.8],[175,138.8],[168,132.8],[161,126.8],[159,122.8],[157,120.8],[157,118.8],[157,117.8],[157,116.8],[158,115.8],[159,114.8],[167,113.8],[186,112.8],[199,112.8],[215,112.8],[240,112.8],[253,112.8],[266,112.8],[277,113.8],[282,117.8],[284,119.8],[286,120.8],[286,121.8],[286,123.8],[286,126.8],[284,127.8],[281,128.8],[272,130.8],[263,133.8],[252,134.8],[233,135.8],[219,135.8],[196,135.8],[184,135.8],[178,134.8],[163,132.8],[161,130.8],[158,126.8],[156,112.8],[156,101.8],[156,89.8],[156,79.8],[161,75.8],[167,72.8],[183,69.8],[202,69.8],[219,69.8],[239,69.8],[251,69.8],[261,70.8],[264,71.8],[267,79.8],[268,81.8],[268,90.8],[269,97.8],[269,105.8],[269,115.8],[267,116.8],[266,120.8],[264,122.8],[263,123.8],[261,124.8],[254,124.8],[246,124.8],[233,124.8],[209,121.8],[197,120.8],[183,117.8],[167,114.8],[155,109.8],[152,107.8],[148,101.8],[148,98.8],[148,96.8],[148,95.8],[150,93.8],[159,91.8],[174,90.8],[192,90.8],[221,89.8],[257,89.8],[288,89.8],[315,89.8],[352,89.8],[366,89.8],[376,89.8],[378,90.8],[378,93.8],[378,95.8],[378,100.8],[376,107.8],[370,110.8],[363,117.8],[349,125.8],[319,134.8],[285,144.8],[258,151.8],[223,156.8],[175,158.8],[123,158.8],[84,158.8],[37,158.8],[0,157.8],[-7,-12.2],[23,-12.2],[49,-11.2],[79,-6.2],[116,-3.2],[150,9.8],[165,15.8],[176,17.8],[189,26.8],[192,30.8],[194,40.8],[195,47.8],[195,60.8],[195,65.8],[194,69.8],[192,73.8],[184,76.8],[182,78.8],[177,79.8],[170,79.8],[162,80.8],[148,80.8],[133,80.8],[121,80.8],[115,80.8],[112,79.8],[111,77.8],[110,75.8],[110,74.8],[110,72.8],[113,62.8],[115,52.8],[124,44.8],[134,38.8],[151,26.8],[156,24.8],[166,21.8],[177,20.8],[179,20.8],[180,20.8],[181,20.8],[181,21.8],[181,23.8],[181,25.8],[181,28.8],[181,29.8],[181,32.8],[181,33.8],[181,35.8]], [[113,15.8],[110,17.8],[108,18.8],[106,21.8],[103,22.8],[101,24.8],[100,31.8],[98,41.8],[97,48.8],[97,56.8],[97,66.8],[97,81.8],[97,89.8],[97,102.8],[97,109.8],[98,114.8],[102,120.8],[105,122.8],[107,124.8],[114,125.8],[122,126.8],[132,126.8],[147,126.8],[155,126.8],[165,124.8],[182,116.8],[191,108.8],[197,103.8],[200,100.8],[204,89.8],[204,88.8],[204,85.8],[204,82.8],[204,80.8],[201,77.8],[195,70.8],[185,68.8],[174,66.8],[166,63.8],[152,61.8],[137,61.8],[125,61.8],[115,61.8],[100,63.8],[88,67.8],[81,72.8],[78,75.8],[77,86.8],[75,91.8],[75,96.8],[76,107.8],[78,112.8],[79,114.8],[82,118.8],[84,120.8],[92,123.8],[100,123.8],[113,124.8],[128,124.8],[143,124.8],[157,124.8],[184,120.8],[224,107.8],[254,98.8],[281,73.8],[303,47.8],[314,38.8],[315,21.8],[315,6.8],[314,-5.2],[306,-15.2],[296,-27.2],[283,-28.2],[272,-30.2],[252,-32.2],[235,-33.2],[203,-33.2],[173,-33.2],[143,-28.2],[115,-18.2],[89,4.8],[69,25.8],[50,39.8],[41,66.8],[33,85.8],[33,107.8],[33,133.8],[36,145.8],[40,159.8],[50,172.8],[60,177.8],[71,179.8],[84,182.8],[93,183.8],[108,183.8],[116,183.8],[126,183.8],[137,180.8],[146,176.8],[156,173.8],[167,166.8],[170,155.8],[172,152.8],[172,147.8],[172,136.8],[171,127.8],[169,122.8],[160,114.8],[154,108.8],[146,105.8],[142,104.8],[136,103.8],[129,103.8],[127,103.8],[121,103.8],[118,105.8],[116,112.8],[116,114.8],[115,116.8],[115,118.8],[118,120.8],[121,122.8],[126,124.8],[137,125.8],[149,125.8],[163,128.8],[186,128.8],[211,128.8],[239,128.8],[270,127.8],[296,124.8],[325,121.8],[355,105.8],[363,103.8],[367,94.8],[368,89.8],[368,81.8],[365,77.8],[353,66.8],[344,58.8],[333,49.8],[314,46.8],[292,40.8],[274,39.8],[249,39.8],[234,39.8],[220,40.8],[203,53.8],[194,60.8],[182,74.8],[178,89.8],[176,104.8],[176,119.8],[176,132.8],[176,147.8],[177,155.8],[184,162.8],[189,164.8],[195,165.8],[205,165.8],[218,165.8],[227,165.8],[238,163.8],[248,152.8],[254,143.8],[259,133.8],[261,117.8],[261,109.8],[261,96.8],[261,85.8],[259,80.8],[256,77.8],[252,66.8],[250,64.8],[243,63.8],[239,62.8],[229,62.8],[210,62.8],[198,62.8],[188,64.8],[181,71.8],[171,83.8],[168,91.8],[167,105.8],[167,116.8],[167,124.8],[167,126.8],[167,129.8],[170,132.8],[172,132.8],[173,132.8],[174,132.8],[175,132.8],[176,131.8],[177,130.8],[177,129.8],[179,127.8],[179,126.8],[180,124.8],[181,122.8],[181,118.8],[182,116.8]], [[139,76.8],[137,76.8],[134,76.8],[132,76.8],[131,76.8],[130,76.8],[127,76.8],[127,77.8],[125,78.8],[125,81.8],[124,86.8],[124,95.8],[124,114.8],[124,122.8],[124,136.8],[124,151.8],[125,159.8],[130,173.8],[132,177.8],[142,182.8],[150,184.8],[162,187.8],[179,187.8],[209,187.8],[224,187.8],[246,180.8],[275,170.8],[295,154.8],[302,141.8],[313,120.8],[315,109.8],[315,94.8],[315,80.8],[312,69.8],[308,60.8],[291,48.8],[282,40.8],[268,38.8],[257,36.8],[249,35.8],[232,35.8],[212,35.8],[208,35.8],[198,37.8],[187,40.8],[182,48.8],[175,53.8],[168,60.8],[165,67.8],[161,75.8],[161,81.8],[159,92.8],[159,94.8],[159,96.8],[161,99.8],[162,100.8],[165,100.8],[167,101.8],[176,101.8],[183,101.8],[191,98.8],[209,96.8],[220,93.8],[229,85.8],[235,79.8],[237,74.8],[238,63.8],[238,58.8],[238,56.8],[236,50.8],[230,44.8],[218,37.8],[205,29.8],[186,25.8],[171,25.8],[148,25.8],[115,25.8],[77,29.8],[46,53.8],[17,76.8],[3,94.8],[-5,117.8],[-9,138.8],[-11,162.8],[-11,173.8],[-7,185.8],[5,196.8],[19,205.8],[29,210.8],[40,211.8],[52,211.8],[69,211.8],[89,211.8],[105,209.8],[118,205.8],[134,203.8],[153,193.8],[174,180.8],[195,161.8],[205,149.8],[208,140.8],[209,131.8],[210,124.8],[210,119.8],[210,110.8],[208,102.8],[206,100.8],[198,94.8],[190,91.8],[184,89.8],[169,87.8],[164,87.8],[155,87.8],[144,87.8],[142,88.8],[140,90.8],[139,96.8],[138,99.8],[138,103.8],[138,117.8],[139,128.8],[142,137.8],[149,143.8],[158,147.8],[168,151.8],[179,153.8],[198,154.8],[211,154.8],[230,154.8],[245,154.8],[259,152.8],[266,145.8],[269,138.8],[272,133.8],[272,124.8],[272,109.8],[272,96.8],[267,82.8],[252,68.8],[235,57.8],[224,54.8],[209,51.8],[186,51.8],[171,51.8],[152,52.8],[133,56.8],[115,64.8],[110,75.8],[103,78.8],[103,84.8],[101,99.8],[101,103.8],[101,113.8],[102,120.8],[104,122.8],[110,124.8],[115,125.8],[124,125.8],[135,125.8],[140,125.8],[149,124.8],[166,116.8],[176,104.8],[186,95.8],[195,80.8],[198,59.8],[198,44.8],[196,30.8],[193,15.8],[181,0.8],[169,-6.2],[156,-15.2],[137,-19.2],[116,-20.2],[102,-20.2],[88,-18.2],[76,-11.2],[70,8.8],[67,21.8],[65,38.8],[65,63.8],[65,76.8],[69,86.8],[73,105.8],[83,109.8],[91,115.8],[99,117.8],[109,117.8],[124,117.8],[128,117.8],[138,117.8],[149,116.8],[153,114.8],[160,109.8],[164,103.8],[169,99.8],[171,90.8],[171,88.8],[171,79.8],[171,74.8],[170,72.8],[168,70.8],[166,70.8],[163,69.8],[161,69.8],[159,69.8],[152,70.8],[147,77.8],[141,83.8],[137,89.8],[134,100.8],[133,108.8],[132,118.8],[132,129.8],[132,137.8],[134,147.8],[140,154.8],[150,160.8],[165,161.8],[173,162.8],[183,162.8],[198,162.8],[202,162.8],[212,159.8],[224,148.8],[230,137.8],[238,120.8],[240,102.8],[240,87.8],[238,74.8],[224,58.8],[219,47.8],[203,37.8],[191,25.8],[182,17.8],[168,16.8],[153,16.8],[145,16.8],[135,17.8],[131,24.8],[128,27.8],[126,36.8],[125,45.8],[125,52.8],[125,56.8],[125,59.8],[125,60.8],[125,61.8],[125,62.8],[126,62.8],[127,62.8]], [[194,36.8],[191,35.8],[188,34.8],[183,33.8],[176,33.8],[168,33.8],[166,33.8],[156,33.8],[154,33.8],[149,35.8],[141,37.8],[138,45.8],[132,50.8],[128,60.8],[125,75.8],[125,83.8],[124,97.8],[124,108.8],[124,120.8],[124,130.8],[124,141.8],[126,149.8],[134,159.8],[139,163.8],[149,166.8],[164,167.8],[176,169.8],[186,169.8],[201,169.8],[209,169.8],[223,167.8],[239,163.8],[243,159.8],[246,157.8],[247,154.8],[249,151.8],[250,149.8],[250,144.8],[250,141.8],[250,138.8],[248,137.8],[246,134.8],[245,132.8],[243,130.8],[242,128.8],[239,128.8],[236,128.8],[234,127.8],[229,127.8],[227,127.8],[225,127.8],[224,128.8],[223,129.8],[222,131.8],[222,132.8],[222,134.8],[223,136.8],[224,137.8],[225,138.8],[226,138.8],[227,138.8]] ]}'; 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