Regular Expressions 101

Save & Manage Regex

  • Current Version: 1
  • Save & Share
  • Community Library

Flavor

  • PCRE2 (PHP)
  • ECMAScript (JavaScript)
  • Python
  • Golang
  • Java
  • .NET 7.0 (C#)
  • Rust
  • PCRE (Legacy)
  • Regex Flavor Guide

Function

  • Match
  • Substitution
  • List
  • Unit Tests
Sponsors
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
Processing...

Test String

Code Generator

Generated Code

using System; using System.Text.RegularExpressions; public class Example { public static void Main() { string pattern = @"^.*?(?=\=)=\s""(?P<Severity>.*?(?=\""))"".*?(?=Gauge32).*?(?=:):\s(?P<EventCount>\d+).*?(?=AlarmOriginEntity).*?(?=\:):\s+""(?P<OriginEntity>.*?(?=\""))"".*?(?=\"")""(?P<OriginHost>.*?(?=\""))"".*?(?=\"")""(?P<ImpactedHost>.*?(?=\""))"".*?(?=\"")""(?P<ImpactedApp>.*?(?=\""))"".*?(?=\"")""(?P<VendorMessageID>.*?(?=\""))"".*?(?=\"")""(?P<MPERuleName>.*?(?=\""))"".*?(?=\"")""(?P<EventDirection>.*?(?=\""))"".*?(?=\"")""(?P<OriginZone>.*?(?=\""))"".*?(?=\"")""(?P<ImpactedZone>.*?(?=\""))"".*?(?=\"")""(?P<ImpactedEntity>.*?(?=\""))"".*?(?=\"")""(?P<OriginLocation>.*?(?=\""))"".*?(?=\"")""(?P<ImpactedLocation>.*?(?=\""))"".*?(?=\"")""(?P<OriginNetwork>.*?(?=\""))"".*?(?=\"")""(?P<ImpactedNetwork>.*?(?=\""))"".*?(?=\"")""(?P<OriginPort>.*?(?=\""))"".*?(?=\"")""(?P<ImpactedPort>.*?(?=\""))"".*?(?=\"")""(?P<AlarmProtocol>.*?(?=\""))"".*?(?=\"")""(?P<OriginUser>.*?(?=\""))"".*?(?=\"")""(?P<ImpactedUser>.*?(?=\""))"".*?(?=\"")""(?P<AlarmObject>.*?(?=\""))"".*?(?=\"")""(?P<AlarmSender>.*?(?=\""))"".*?(?=\"")""(?P<AlarmRecipient>.*?(?=\""))"".*?(?=\"")""(?P<AlarmSubject>.*?(?=\""))"".*?(?=\"")""(?P<AlarmGroup>.*?(?=\""))"".*?(?=\"")""(?P<AlarmDomain>.*?(?=\""))"".*?(?=\"")""(?P<AlarmSession>.*?(?=\""))"".*?(?=\"")""(?P<AlarmProcessName>.*?(?=\""))"".*?(?=\"")""(?P<AlarmURL>.*?(?=\""))"".*?(?=\"")""(?P<BytesIn>.*?(?=\""))"".*?(?=\"")""(?P<BytesOut>.*?(?=\""))"".*?(?=\"")""(?P<ItemsIn>.*?(?=\""))"".*?(?=\"")""(?P<ItemsOut>.*?(?=\""))"".*?(?=\"")""(?P<Duration>.*?(?=\""))"".*?(?=\"")""(?P<Amount>.*?(?=\""))"".*?(?=\"")""(?P<Quantity>.*?(?=\""))"".*?(?=\"")""(?P<Rate>.*?(?=\""))"".*?(?=\"")""(?P<Size>.*?(?=\""))"".*?(?=v\=)(?P<Message>.*?(?=\<\/aie\>)).*?(?=\=)=\s""(?P<KBWebRefernce>.*?(?=\""))"".*?(?=\"")""(?P<OriginMACAddress>.*?(?=\""))"".*?(?=\"")""(?P<ImpactedMACAddress>.*?(?=\""))"".*?(?=\"")""(?P<OriginNATIPAddress>.*?(?=\""))"".*?(?=\"")""(?P<ImpactedNATIPAddress>.*?(?=\""))"".*?(?=\"")""(?P<OriginInterface>.*?(?=\""))"".*?(?=\"")""(?P<ImpactedInterface>.*?(?=\""))"".*?(?=\"")""(?P<AlarmPID>.*?(?=\""))"".*?(?=\"")""(?P<AlarmVersion>.*?(?=\""))"".*?(?=\"")""(?P<AlarmCommand>.*?(?=\""))"".*?(?=\"")""(?P<AlarmObjectName>.*?(?=\""))"".*?(?=\"")""(?P<OriginNATPORT>.*?(?=\""))"".*?(?=\"")""(?P<ImpactedNATPort>.*?(?=\""))"""; string input = @"#011LOGRHYTHM-ARM-MIB::armAlarmSeverity = ""#011LOGRHYTHM-ARM-MIB::armAlarmEventDateMin = STRING: ""6/22/2016 1:39:14 PM""#011LOGRHYTHM-ARM-MIB::armAlarmEventDateMax = STRING: ""6/22/2016 1:39:14 PM""#011LOGRHYTHM-ARM-MIB::armAlarmEventCount = Gauge32: 1#011LOGRHYTHM-ARM-MIB::armAlarmOriginEntity = STRING: ""Global Entity""#011LOGRHYTHM-ARM-MIB::armAlarmOriginHost = STRING: ""10.10.129.74""#011LOGRHYTHM-ARM-MIB::armAlarmImpactedHost = STRING: ""216.58.216.238""#011LOGRHYTHM-ARM-MIB::armAlarmImpactedApplication = ""#011LOGRHYTHM-ARM-MIB::armAlarmVendorMessageID = ""#011LOGRHYTHM-ARM-MIB::armAlarmMPERuleName = ""#011LOGRHYTHM-ARM-MIB::armAlarmEventDirection = STRING: ""Unknown""#011LOGRHYTHM-ARM-MIB::armAlarmOriginZone = STRING: ""Internal""#011LOGRHYTHM-ARM-MIB::armAlarmImpactedZone = STRING: ""External""#011LOGRHYTHM-ARM-MIB::armAlarmImpactedEntity = STRING: ""Global Entity""#011LOGRHYTHM-ARM-MIB::armAlarmOriginLocation = ""#011LOGRHYTHM-ARM-MIB::armAlarmImpactedLocation = ""#011LOGRHYTHM-ARM-MIB::armAlarmOriginNetwork = ""#011LOGRHYTHM-ARM-MIB::armAlarmImpactedNetwork = ""#011LOGRHYTHM-ARM-MIB::armAlarmOriginPort = ""#011LOGRHYTHM-ARM-MIB::armAlarmImpactedPort = ""#011LOGRHYTHM-ARM-MIB::armArmAlarmProtocol = ""#011LOGRHYTHM-ARM-MIB::armAlarmLogin = ""#011LOGRHYTHM-ARM-MIB::armAlarmLogin = ""#011LOGRHYTHM-ARM-MIB::armAlarmObject = ""#011LOGRHYTHM-ARM-MIB::armAlarmSender = ""#011LOGRHYTHM-ARM-MIB::armAlarmRecipient = ""#011LOGRHYTHM-ARM-MIB::armAlarmSubject = ""#011LOGRHYTHM-ARM-MIB::armAlarmGroup = ""#011LOGRHYTHM-ARM-MIB::armAlarmDomain = ""#011LOGRHYTHM-ARM-MIB::armAlarmSession = ""#011LOGRHYTHM-ARM-MIB::armAlarmProcess = ""#011LOGRHYTHM-ARM-MIB::armAlarmURL = ""#011LOGRHYTHM-ARM-MIB::armAlarmBytesIn = ""#011LOGRHYTHM-ARM-MIB::armAlarmBytesOut = ""#011LOGRHYTHM-ARM-MIB::armAlarmItemsIn = ""#011LOGRHYTHM-ARM-MIB::armAlarmItemsOut = ""#011LOGRHYTHM-ARM-MIB::armAlarmDuration = ""#011LOGRHYTHM-ARM-MIB::armAlarmAmount = ""#011LOGRHYTHM-ARM-MIB::armAlarmQuantity = ""#011LOGRHYTHM-ARM-MIB::armAlarmRate = ""#011LOGRHYTHM-ARM-MIB::armAlarmSize = ""#011LOGRHYTHM-ARM-MIB::armAlarmLogs = STRING: ""MSG: <aie v=\""1\""><_0 DIP=\""216.58.216.238\"" NormalMsgDate=\""2016-06-22 19:39:07\"" NormalMsgDateLower=\""2016-06-22 19:39:07\"" NormalMsgDateUpper=\""2016-06-22 19:39:08\"" RuleBlockType=\""1\"" SIP=\""10.10.129.74\"" /><_ AIERuleID=\""550\"" DateEdited=\""2015-10-15 19:52:11\"" /></aie>""#011LOGRHYTHM-ARM-MIB::armAlarmKBWebReference = ""#011LOGRHYTHM-ARM-MIB::armAlarmOriginMAC = ""#011LOGRHYTHM-ARM-MIB::armAlarmImpactedMAC = ""#011LOGRHYTHM-ARM-MIB::armAlarmOriginNATIP = ""#011LOGRHYTHM-ARM-MIB::armAlarmImpactedNATIP = ""#011LOGRHYTHM-ARM-MIB::armAlarmOriginInterface = ""#011LOGRHYTHM-ARM-MIB::armAlarmImpactedInterface = ""#011LOGRHYTHM-ARM-MIB::armAlarmPID = STRING: ""0""#011LOGRHYTHM-ARM-MIB::armAlarmVersion = ""#011LOGRHYTHM-ARM-MIB::armAlarmCommand = ""#011LOGRHYTHM-ARM-MIB::armAlarmObjectName = ""#011LOGRHYTHM-ARM-MIB::armAlarmOriginNATPort = STRING: ""0""#011LOGRHYTHM-ARM-MIB::armAlarmImpactedNATPort = STRING: ""0"" "; Match m = Regex.Match(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