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

/
/
m

Test String

Code Generator

Generated Code

using System; using System.Text.RegularExpressions; public class Example { public static void Main() { string pattern = @"(?<cdrRecordType>d+)\,(?<globalCallID_callManagerId>d+)\,(?<globalCallID_callId>d+)\,(?<origLegCallIdentifier>d+)\,(?<dateTimeOrigination>d+)\,(?<origNodeId>d+)\,(?<origSpan>d+)\,(?<origIpAddr>d+)\,(?<callingPartyNumber>d+)\,(?<callingPartyUnicodeLoginUserID>d+)\,(?<origCause_location>d+)\,(?<origCause_value>d+)\,(?<origPrecedenceLevel>d+)\,(?<origMediaTransportAddress_IP>d+)\,(?<origMediaTransportAddress_Port>d+)\,(?<origMediaCap_payloadCapability>d+)\,(?<origMediaCap_maxFramesPerPacket>d+)\,(?<origMediaCap_g723BitRate>d+)\,(?<origVideoCap_Codec>d+)\,(?<origVideoCap_Bandwidth>d+)\,(?<origVideoCap_Resolution>d+)\,(?<origVideoTransportAddress_IP>d+)\,(?<origVideoTransportAddress_Port>d+)\,(?<origRSVPAudioStat>d+)\,(?<origRSVPVideoStat>d+)\,(?<destLegIdentifier>d+)\,(?<destNodeId>d+)\,(?<destSpan>d+)\,(?<destIpAddr>d+)\,(?<originalCalledPartyNumber>d+)\,(?<finalCalledPartyNumber>d+)\,(?<finalCallPartyUnicodeLoginUserID>d+)\,(?<destCause_location>d+)\,(?<destCause_value>d+)\,(?<destPrecedenceLevel>d+)\,(?<destMediaTransportAddress_IP>d+)\,(?<destMediaTransportAddress_Port>d+)\,(?<destMediaCap_payloadCapability>d+)\,(?<destMediaCap_maxFramesPerPacket>d+)\,(?<destMediaCap_g723BitRate>d+)\,(?<destVideoCap_Codec>d+)\,(?<destVideoCap_Bandwidth>d+)\,(?<destVideoCap_Resolution>d+)\,(?<destVideoTransportAddress_IP>d+)\,(?<destVideoTransportAddress_Port>d+)\,(?<destRSVPAudioStat>d+)\,(?<destRSVPVideoStat>d+)\,(?<dateTimeConnect>d+)\,(?<dateTimeDisconnect>d+)\,(?<lastRedirectDn>d+)\,(?<pkid>d+)\,(?<originalCallPartyNumberPartition>d+)\,(?<callingPartyNumberPartition>d+)\,(?<finalCalledPartyNumberPartition>d+)\,(?<lastRedirectDnPartition>d+)\,(?<duration>d+)\,(?<origDeviceName>d+)\,(?<destDeviceName>d+)\,(?<origCallTerminationOnBehalfOf>d+)\,(?<destCallTerminationOnBehalfOf>d+)\,(?<origCallPartyRedirectOnBehalfOf>d+)\,(?<lastRedirectRedirectOnBehalfOf>d+)\,(?<origCalledPartyRedirectReason>d+)\,(?<lastRedirectRedirectReason>d+)\,(?<destConversationId>d+)\,(?<globalCallId_ClusterID>d+)\,(?<joinOnBehalfOf>d+)\,(?<comment>d+)\,(?<authCodeDescription>d+)\,(?<authorizationLevel>d+)\,(?<clientMatterCode>d+)\,(?<origDTMFMethod>d+)\,(?<destDTMFMethod>d+)\,(?<callSecuredStatus>d+)\,(?<origConversationId>d+)\,(?<origMediaCap_Bandwidth>d+)\,(?<destMediaCap_Bandwidth>d+)\,(?<authorizationCodeValue>d+)\,(?<outpulsedCallingPartyNumber>d+)\,(?<outpulsedCalledPartyNumber>d+)\,(?<origIpv4v6Addr>d+)\,(?<destIpv4v6Addr>d+)\,(?<origVideoCap_Codec_Channel2>d+)\,(?<origVideoCap_Bandwidth_Channel2>d+)\,(?<origVideoCap_Resolution_Channel2>d+)\,(?<origVideoTransAdd_IP_Channel2>d+)\,(?<origVideoTransAdd_Port_Channel2>d+)\,(?<origVideoChannel_Role_Channel2>d+)\,(?<destVideoCap_Codec_Channel2>d+)\,(?<destVideoCap_Bandwidth_Channel2>d+)\,(?<destVideoCap_Resolution_Channel2>d+)\,(?<destVideoTransAdd_IP_Channel2>d+)\,(?<destVideoTransAdd_Port_Channel2>d+)\,(?<destVideoChannel_Role_Channel2>d+)\,(?<IncomingProtocolID>d+)\,(?<IncomingProtocolCallRef>d+)\,(?<OutgoingProtocolID>d+)\,(?<OutgoingProtocolCallRef>d+)\,(?<currentRoutingReason>d+)\,(?<origRoutingReason>d+)\,(?<lastRedirectingRoutingReason>d+)\,(?<huntPilotPartition>d+)\,(?<huntPilotDN>d+)\,(?<calledPartyPatternUsage>d+)\,(?<IncomingICID>d+)\,(?<IncomingOrigIOI>d+)\,(?<IncomingTermIOI>d+)\,(?<OutgoingICID>d+)\,(?<OutgoingOrigIOI>d+)\,(?<OutgoingTermIOI>d+)\,(?<outpulsedOrilCalledPartyNumber>d+)\,(?<outpulsedLastRedirectingNumber>d+)\,(?<wasCallQueued>d+)\,(?<totalWaitTimeInQueue>d+)\,(?<callingPartyNumber_uri>d+)\,(?<originalCalledPartyNumber_uri>d+)\,(?<finalCalledPartyNumber_uri>d+)\,(?<lastRedirectDn_uri>d+)\,(?<mobileCallingPartyNumber>d+)\,(?<finalMobileCalledPartyNumber>d+)\,(?<origMobileDeviceName>d+)\,(?<destMobileDeviceName>d+)\,(?<origMobileCallDuration>d+)\,(?<destMobileCallDuration>d+)\,(?<mobileCallType>d+)\,(?<originalCalledPartyPattern>d+)\,(?<finalCalledPartyPattern>d+)\,(?<lastRedirectingPartyPattern>d+)\,(?<huntPilotPattern>d+)\, "; string input = @"""cdrRecordType"",""globalCallID_callManagerId"",""globalCallID_callId"",""origLegCallIdentifier"",""dateTimeOrigination"",""origNodeId"",""origSpan"",""origIpAddr"",""callingPartyNumber"",""callingPartyUnicodeLoginUserID"",""origCause_location"",""origCause_value"",""origPrecedenceLevel"",""origMediaTransportAddress_IP"",""origMediaTransportAddress_Port"",""origMediaCap_payloadCapability"",""origMediaCap_maxFramesPerPacket"",""origMediaCap_g723BitRate"",""origVideoCap_Codec"",""origVideoCap_Bandwidth"",""origVideoCap_Resolution"",""origVideoTransportAddress_IP"",""origVideoTransportAddress_Port"",""origRSVPAudioStat"",""origRSVPVideoStat"",""destLegIdentifier"",""destNodeId"",""destSpan"",""destIpAddr"",""originalCalledPartyNumber"",""finalCalledPartyNumber"",""finalCalledPartyUnicodeLoginUserID"",""destCause_location"",""destCause_value"",""destPrecedenceLevel"",""destMediaTransportAddress_IP"",""destMediaTransportAddress_Port"",""destMediaCap_payloadCapability"",""destMediaCap_maxFramesPerPacket"",""destMediaCap_g723BitRate"",""destVideoCap_Codec"",""destVideoCap_Bandwidth"",""destVideoCap_Resolution"",""destVideoTransportAddress_IP"",""destVideoTransportAddress_Port"",""destRSVPAudioStat"",""destRSVPVideoStat"",""dateTimeConnect"",""dateTimeDisconnect"",""lastRedirectDn"",""pkid"",""originalCalledPartyNumberPartition"",""callingPartyNumberPartition"",""finalCalledPartyNumberPartition"",""lastRedirectDnPartition"",""duration"",""origDeviceName"",""destDeviceName"",""origCallTerminationOnBehalfOf"",""destCallTerminationOnBehalfOf"",""origCalledPartyRedirectOnBehalfOf"",""lastRedirectRedirectOnBehalfOf"",""origCalledPartyRedirectReason"",""lastRedirectRedirectReason"",""destConversationId"",""globalCallId_ClusterID"",""joinOnBehalfOf"",""comment"",""authCodeDescription"",""authorizationLevel"",""clientMatterCode"",""origDTMFMethod"",""destDTMFMethod"",""callSecuredStatus"",""origConversationId"",""origMediaCap_Bandwidth"",""destMediaCap_Bandwidth"",""authorizationCodeValue"",""outpulsedCallingPartyNumber"",""outpulsedCalledPartyNumber"",""origIpv4v6Addr"",""destIpv4v6Addr"",""origVideoCap_Codec_Channel2"",""origVideoCap_Bandwidth_Channel2"",""origVideoCap_Resolution_Channel2"",""origVideoTransportAddress_IP_Channel2"",""origVideoTransportAddress_Port_Channel2"",""origVideoChannel_Role_Channel2"",""destVideoCap_Codec_Channel2"",""destVideoCap_Bandwidth_Channel2"",""destVideoCap_Resolution_Channel2"",""destVideoTransportAddress_IP_Channel2"",""destVideoTransportAddress_Port_Channel2"",""destVideoChannel_Role_Channel2"",""IncomingProtocolID"",""IncomingProtocolCallRef"",""OutgoingProtocolID"",""OutgoingProtocolCallRef"",""currentRoutingReason"",""origRoutingReason"",""lastRedirectingRoutingReason"",""huntPilotPartition"",""huntPilotDN"",""calledPartyPatternUsage"",""IncomingICID"",""IncomingOrigIOI"",""IncomingTermIOI"",""OutgoingICID"",""OutgoingOrigIOI"",""OutgoingTermIOI"",""outpulsedOriginalCalledPartyNumber"",""outpulsedLastRedirectingNumber"",""wasCallQueued"",""totalWaitTimeInQueue"",""callingPartyNumber_uri"",""originalCalledPartyNumber_uri"",""finalCalledPartyNumber_uri"",""lastRedirectDn_uri"",""mobileCallingPartyNumber"",""finalMobileCalledPartyNumber"",""origMobileDeviceName"",""destMobileDeviceName"",""origMobileCallDuration"",""destMobileCallDuration"",""mobileCallType"",""originalCalledPartyPattern"",""finalCalledPartyPattern"",""lastRedirectingPartyPattern"",""huntPilotPattern"" INTEGER,INTEGER,INTEGER,INTEGER,INTEGER,INTEGER,INTEGER,INTEGER,VARCHAR(50),VARCHAR(128),INTEGER,INTEGER,INTEGER,INTEGER,INTEGER,INTEGER,INTEGER,INTEGER,INTEGER,INTEGER,INTEGER,INTEGER,INTEGER,VARCHAR(64),VARCHAR(64),INTEGER,INTEGER,INTEGER,INTEGER,VARCHAR(50),VARCHAR(50),VARCHAR(128),INTEGER,INTEGER,INTEGER,INTEGER,INTEGER,INTEGER,INTEGER,INTEGER,INTEGER,INTEGER,INTEGER,INTEGER,INTEGER,VARCHAR(64),VARCHAR(64),INTEGER,INTEGER,VARCHAR(50),UNIQUEIDENTIFIER,VARCHAR(50),VARCHAR(50),VARCHAR(50),VARCHAR(50),INTEGER,VARCHAR(129),VARCHAR(129),INTEGER,INTEGER,INTEGER,INTEGER,INTEGER,INTEGER,INTEGER,VARCHAR(50),INTEGER,VARCHAR(2048),VARCHAR(50),INTEGER,VARCHAR(32),INTEGER,INTEGER,INTEGER,INTEGER,INTEGER,INTEGER,VARCHAR(32),VARCHAR(50),VARCHAR(50),VARCHAR(64),VARCHAR(64),INTEGER,INTEGER,INTEGER,INTEGER,INTEGER,INTEGER,INTEGER,INTEGER,INTEGER,INTEGER,INTEGER,INTEGER,INTEGER,VARCHAR(32),INTEGER,VARCHAR(32),INTEGER,INTEGER,INTEGER,VARCHAR(50),VARCHAR(50),INTEGER,VARCHAR(50),VARCHAR(50),VARCHAR(50),VARCHAR(50),VARCHAR(50),VARCHAR(50),VARCHAR(50),VARCHAR(50),INTEGER,INTEGER,VARCHAR(255),VARCHAR(255),VARCHAR(255),VARCHAR(255),VARCHAR(50),VARCHAR(50),VARCHAR(129),VARCHAR(129),INTEGER,INTEGER,INTEGER,VARCHAR(50),VARCHAR(50),VARCHAR(50),VARCHAR(50) 1,2,66619,37842527,1521601412,2,37842527,768283402,""8345"","",0,0,4,561581578,20952,4,20,0,0,0,0,0,0,""0"",""0"",37842528,2,0,-1939586038,""+552125403404"",""+552125403404"","",0,16,4,-1939586038,20580,4,20,0,0,0,0,0,0,""0"",""0"",1521601417,1521602306,""+552125403404"",""df8a12f7-6aa7-4ffb-b97f-eb331c392ec9"",""GLOBAL_DN_E164_PT"","",""GLOBAL_DN_E164_PT"",""GLOBAL_DN_E164_PT"",889,""TRK-SME"",""SEP10BD1800DEC5"",0,12,0,0,0,0,0,""GloboUC"",0,"","",0,"",3,3,0,0,64,64,"","","",""10.14.121.33"",""10.68.100.140"",0,0,0,0,0,0,0,0,0,0,0,0,1,""6ECE5F800001000000175DAB2DCB130A"",0,"",0,0,0,"","",2,"","","","","","","","",0,0,"","","","","","","","",0,0,0,""+552125403404"",""+552125403404"",""+552125403404"","" "; RegexOptions options = RegexOptions.Multiline; Match m = Regex.Match(input, pattern, options); 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