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

r"
"
gm

Test String

Substitution

Processing...

Code Generator

Generated Code

using System; using System.Text.RegularExpressions; public class Example { public static void Main() { string pattern = @"\[*([^\[,\]]*),([^,\[\]]*)\][,\]]*"; string substitution = @"\g<2>,\g<1>;"; string input = @"[[[0.651408138,49.683426254],[0.651182225,49.683488415],[0.650805682,49.683602503],[0.650507876,49.683721707],[0.650202076,49.683864128],[0.649954867,49.683997792],[0.649773064,49.684094962],[0.649330872,49.684371387],[0.649175285,49.684470861],[0.648550124,49.684869601],[0.647808782,49.685354188],[0.64749173,49.68556021],[0.647085546,49.685836424],[0.646939518,49.685938777],[0.645569984,49.685258746],[0.644171872,49.684568256],[0.643448757,49.685017212],[0.64267569,49.685557789],[0.642518186,49.685698569],[0.64318596,49.686061198],[0.642897975,49.686357667],[0.642327656,49.686948015],[0.641719635,49.687574486],[0.641320197,49.687973968],[0.641219463,49.688085283],[0.641550032,49.688278672],[0.641019439,49.688727749],[0.641985518,49.689473724],[0.641209839,49.689738263],[0.641663408,49.690420366],[0.641316733,49.690576356],[0.641706636,49.691527807],[0.642000208,49.692133992],[0.642225121,49.692696594],[0.642005192,49.693319796],[0.641926928,49.693544813],[0.641600478,49.694374504],[0.642230507,49.694475708],[0.643063035,49.694603304],[0.643725163,49.694699728],[0.644330196,49.694802235],[0.644642054,49.694861309],[0.644553775,49.694972867],[0.644215304,49.695311508],[0.643796544,49.695738489],[0.643666496,49.695884296],[0.643880344,49.69599541],[0.644457828,49.696335601],[0.644975843,49.696643176],[0.645079463,49.69668024],[0.645535133,49.696927275],[0.645712576,49.697046671],[0.64574732,49.697165104],[0.645760239,49.697215695],[0.645992804,49.697432343],[0.646230894,49.697347953],[0.647640815,49.696763937],[0.64869469,49.696327643],[0.649715424,49.695918567],[0.649925521,49.695839922],[0.650279276,49.695862035],[0.650693229,49.695870926],[0.651289345,49.695866252],[0.652553642,49.697761333],[0.653356845,49.69780469],[0.654102032,49.697813663],[0.654513931,49.69780722],[0.655144659,49.697773528],[0.655964041,49.697705712],[0.656083655,49.69769633],[0.657924145,49.697604115],[0.658808505,49.697569892],[0.65899614,49.698073308],[0.660098609,49.69787607],[0.661214269,49.697662894],[0.661262168,49.697767192],[0.661595352,49.698361496],[0.663043528,49.69833268],[0.664235087,49.698308811],[0.665335332,49.697825622],[0.666571586,49.697307277],[0.666634168,49.697363311],[0.667407528,49.697970532],[0.668345327,49.698740907],[0.669176057,49.69942832],[0.669538297,49.699325587],[0.670122964,49.699085981],[0.670386728,49.698954393],[0.670602962,49.698831783],[0.670890039,49.698553216],[0.671306301,49.698237567],[0.671480013,49.698105153],[0.67238017,49.697387947],[0.673095278,49.696808329],[0.673279571,49.696656338],[0.67343269,49.696702414],[0.673681105,49.696755705],[0.673965234,49.696815971],[0.67435032,49.696880862],[0.674709426,49.696938064],[0.675009808,49.696976164],[0.675501758,49.6970377],[0.675570587,49.696956313],[0.676213657,49.696253047],[0.676958643,49.695441154],[0.677710772,49.694654563],[0.678391818,49.693937626],[0.678213984,49.693856026],[0.678916393,49.693309391],[0.679534253,49.69285463],[0.680134915,49.692350994],[0.679945518,49.6922494],[0.68104538,49.69133997],[0.680742658,49.691170595],[0.680433179,49.690997494],[0.679605941,49.690507984],[0.678835077,49.690242479],[0.679064814,49.690126404],[0.679269059,49.690022427],[0.679518826,49.689861787],[0.679628888,49.689787476],[0.679838259,49.689631458],[0.68008285,49.689432064],[0.680258015,49.689266403],[0.680356428,49.689173891],[0.680518196,49.689028651],[0.680716079,49.688850838],[0.681142949,49.688511984],[0.68118798,49.688466098],[0.681274015,49.688432679],[0.68138513,49.688365578],[0.681573281,49.688280169],[0.680935738,49.68779428],[0.680710324,49.687723462],[0.68062563,49.687696678],[0.68056219,49.687628947],[0.680390645,49.687561852],[0.680107454,49.687451278],[0.679946213,49.687432022],[0.679368149,49.687254695],[0.679310858,49.687112469],[0.679188502,49.68703013],[0.679122824,49.686920106],[0.678954458,49.68669126],[0.678744969,49.686422077],[0.678565775,49.686157067],[0.678531084,49.68597482],[0.678565814,49.68585053],[0.678474447,49.685818222],[0.678412437,49.685780183],[0.678273515,49.685696627],[0.678081704,49.685557227],[0.677829066,49.685323176],[0.677525617,49.685079165],[0.676885017,49.684601283],[0.676627618,49.684625134],[0.676057853,49.684662795],[0.675918689,49.684676318],[0.675380109,49.684728955],[0.674678054,49.68484229],[0.674115649,49.684961886],[0.673710603,49.685094377],[0.673376806,49.685244411],[0.672908752,49.685543796],[0.672497134,49.685759759],[0.672266133,49.685934229],[0.672107188,49.686199972],[0.671909486,49.686403844],[0.671880411,49.686433852],[0.671672289,49.686592578],[0.671255129,49.686747303],[0.670788092,49.686871406],[0.670410965,49.686937899],[0.670304124,49.686941247],[0.670139017,49.686946176],[0.669930101,49.686939479],[0.669544033,49.686897925],[0.669113584,49.686857318],[0.668543806,49.686803252],[0.667980787,49.686752909],[0.667482753,49.686705606],[0.667031098,49.68664391],[0.664186445,49.686494044],[0.66392097,49.68651232],[0.66350782,49.686517871],[0.663486668,49.686586683],[0.662135459,49.686441168],[0.660886381,49.686274229],[0.660273458,49.686224688],[0.660114782,49.686240514],[0.65908153,49.686020174],[0.657988293,49.685748329],[0.657847309,49.685710557],[0.657888738,49.685349978],[0.655984656,49.684661572],[0.653722497,49.683897011],[0.651927108,49.683287944],[0.651408138,49.683426254]]]"; RegexOptions options = RegexOptions.Multiline; Regex regex = new Regex(pattern, options); string result = regex.Replace(input, substitution); } }

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 C#, please visit: https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex(v=vs.110).aspx