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

@"
"
g

Test String

Code Generator

Generated Code

using System; using System.Text.RegularExpressions; public class Example { public static void Main() { string pattern = @"([+-]?(?=\.\d|\d)(?:\d+)?(?:\.?\d*)?(?:[eE][+-]?\d+))"; string input = @"-7.76265716553E+001,-6.31148033142E+001,-5.73922691345E+001,-5.38103637695E+001,-5.16600952148E+001,-4.95847129822E+001,-4.81689414978E+001,-4.69958305359E+001,-4.61010208130E+001,-4.53046951294E+001,-4.53640022278E+001,-4.65055618286E+001,-5.13678970337E+001,-5.61308746338E+001,-4.77712936401E+001,-6.15663051605E+000,-6.16744709015E+000,-7.49333953857E+000,-7.38442659378E+000,-6.26228570938E+000,-6.57908296585E+000,-7.59537887573E+000,-7.43183755875E+000,-6.23343372345E+000,-7.70702409744E+000,-1.08429431915E+001,-4.69756317139E+001,-4.55940208435E+001,-5.03574562073E+001,-6.65668258667E+001,-5.64810142517E+001,-5.13527069092E+001,-4.85807647705E+001,-4.74550819397E+001,-4.66080627441E+001,-4.62032432556E+001,-4.59199676514E+001,-4.57826080322E+001,-4.57874450684E+001,-4.57001113892E+001,-4.56483345032E+001,-4.57628097534E+001,-4.60448646545E+001,-4.61782836914E+001,-4.62703628540E+001,-4.62610549927E+001,-4.65860748291E+001,-4.67022132874E+001,-4.68499641418E+001,-4.70024261475E+001,-4.73190040588E+001,-4.74297828674E+001,-4.75628166199E+001,-4.78372993469E+001,-4.81219329834E+001,-4.81131362915E+001,-4.83158836365E+001,-4.86021614075E+001,-4.87798461914E+001,-4.88457489014E+001,-4.87970848083E+001,-4.92308921814E+001,-4.92529258728E+001,-4.94404411316E+001,-4.93520164490E+001,-4.97943077087E+001,-4.96036415100E+001,-5.00148773193E+001,-5.01489982605E+001,-5.02896537781E+001,-5.03711814880E+001,-5.07100257874E+001,-5.08905906677E+001,-5.10273132324E+001,-5.10545578003E+001,-5.11007804871E+001,-5.12510223389E+001,-5.14304389954E+001,-5.16056137085E+001,-5.16610908508E+001,-5.17760086060E+001,-5.21291580200E+001,-5.21819610596E+001,-5.21607208252E+001,-5.22457122803E+001,-5.23767852783E+001,-5.25701560974E+001,-5.22764816284E+001,-5.23337783813E+001,-5.24362678528E+001,-5.21340370178E+001,-5.23084030151E+001,-5.26199760437E+001,-5.25918540955E+001,-5.23139915466E+001,-5.24451408386E+001,-5.21479873657E+001,-5.23418273926E+001,-5.26621246338E+001,-5.23605918884E+001,-5.23170242310E+001,-5.27033004761E+001,-5.25297088623E+001,-5.25942764282E+001,-5.26434478760E+001,-5.25839614868E+001,-5.26727294922E+001,-5.22096023560E+001,-5.22509078979E+001,-5.23977622986E+001,-5.23610038757E+001,-5.23930168152E+001,-5.23715705872E+001,-5.22516517639E+001,-5.23776435852E+001,-5.21721916199E+001,-5.21216583252E+001,-5.25218620300E+001,-5.26093673706E+001,-5.26998329163E+001,-5.21572837830E+001,-5.22003211975E+001,-5.26706924438E+001,-5.24649505615E+001,-5.21967506409E+001,-5.22106094360E+001,-5.24146842957E+001,-5.25894050598E+001,-5.22559432983E+001,-5.26874504089E+001,-5.26080818176E+001,-5.21933670044E+001,-5.21324424744E+001,-5.22635269165E+001,-5.25657615662E+001,-5.23811683655E+001,-5.23741836548E+001,-5.22197418213E+001,-5.24904174805E+001,-5.22305755615E+001,-5.22149963379E+001,-5.23813056946E+001,-5.22238426208E+001,-5.22887573242E+001,-5.22100105286E+001,-5.22519073486E+001,-5.25531120300E+001,-5.22242431641E+001,-5.26882286072E+001,-5.22565498352E+001,-5.21886405945E+001,-5.25764617920E+001,-5.25389442444E+001,-5.24607391357E+001,-5.25013847351E+001,-5.24470481873E+001,-5.26802558899E+001,-5.21289978027E+001,-5.21622047424E+001,-5.23709144592E+001,-5.25287704468E+001,-5.25145645142E+001,-5.25807495117E+001,-5.26013259888E+001,-5.24394683838E+001,-5.22766151428E+001,-5.24181709290E+001,-5.25081100464E+001,-5.24238243103E+001,-5.26681060791E+001,-5.24720611572E+001,-5.23497924805E+001,-5.22287254333E+001,-5.23819389343E+001,-5.26275444031E+001,-5.26629180908E+001,-5.24650077820E+001,-5.26401596069E+001,-5.24540328979E+001,-5.25329933167E+001,-5.22909278870E+001,-5.21246185303E+001,-5.24595298767E+001,-5.25189743042E+001,-5.23578338623E+001,-5.26726799011E+001,-5.22009735107E+001,-5.22557601929E+001,-5.23468933105E+001,-5.23396797180E+001,-5.21773223877E+001,-5.23407440186E+001,-5.23587074280E+001,-5.24268417358E+001,-5.25630645752E+001,-5.23802452087E+001,-5.26560668945E+001,-5.21600112915E+001,-5.26404838562E+001,-5.23716659546E+001,-5.21437263489E+001"; foreach (Match m in Regex.Matches(input, pattern)) { Console.WriteLine("'{0}' found at index {1}.", m.Value, m.Index); } } }

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