Regular Expressions 101

Save & Share

  • Regex Version: ver. 4
  • 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
No Match

r"
"
gm

Test String

Code Generator

Generated Code

# coding=utf8 # the above tag defines encoding for this document and is for Python 2.x compatibility import re regex = r"LogNet:..-.ReliableBufferOverflow|(?:Warning: Closing connection. Can't send function[^\r\n]*Reliable buffer overflow)" test_str = ("# `reliablebufferoverflow_simple` crash\n\n" "[2024.12.06-12.07.43:682][771]LogStreaming: Display: FlushAsyncLoading(1798): 1 QueuedPackages, 0 AsyncPackages\n" "[2024.12.06-12.07.43:985][819]LogNet: NMT_CloseReason: (Server Disconnect Reasons) steam.76561198027357835:7777\n" "[2024.12.06-12.07.43:985][819]LogNet: - ReliableBufferOverflow\n" "[2024.12.06-12.07.43:985][819]LogNet: UChannel::ReceivedSequencedBunch: Bunch.bClose == true. ChIndex == 0. Calling ConditionalCleanUp.\n\n" "[2024.12.06-17.31.59:411][798]LogNet: Warning: Closing connection. Can't send function 'Client_SendSessionSetting' on 'SMLSessionSettingsRemoteCallObject /Game/FactoryGame/Map/GameLevel01/Persistent_Level.Persistent_Level:PersistentLevel.BP_PlayerController_C_2147471387.SMLSessionSettingsRemoteCallObject_2147471320': Reliable buffer overflow. FieldCache->FieldNetIndex: 1 Max 3. Ch MaxPacket: 1024.\n" "[2024.12.06-17.31.59:411][798]LogNet: UNetConnection::SendCloseReason:\n" "[2024.12.06-17.31.59:412][798]LogNet: - Result=RPCReliableBufferOverflow, ErrorContext=\"RPCReliableBufferOverflow\"\n\n" "[2024.12.13-02.01.30:396][970]LogGame: Warning: Failed To Set primary Slot! Invalid index: [30]\n" "[2024.12.13-02.01.30:398][970]LogNet: NMT_CloseReason: (Server Disconnect Reasons) 80.7.73.10:7777\n" "[2024.12.13-02.01.30:398][970]LogNet: - ReliableBufferOverflow\n" "[2024.12.13-02.01.30:398][970]LogNet: UChannel::ReceivedSequencedBunch: Bunch.bClose == true. ChIndex == 0. Calling ConditionalCleanUp.\n\n" "[2025.01.20-01.32.38:306][997]AnimBlueprintLog: Warning: SLOTNODE: 'FullBodySlot' in animation instance class Anim_Locker_C already exists. Remove duplicates from the animation graph for this class.\n" "[2025.01.20-01.32.38:375][997]LogNet: NMT_CloseReason: (Server Disconnect Reasons) steam.76561199070541262:7777\n" "[2025.01.20-01.32.38:375][997]LogNet: - ReliableBufferOverflow\n" "[2025.01.20-01.32.38:375][997]LogNet: UChannel::ReceivedSequencedBunch: Bunch.bClose == true. ChIndex == 0. Calling ConditionalCleanUp.\n\n" "# More detailed crash (should trigger `reliablebufferoverflow` crash instead of this one!)\n\n" "[2024.12.03-16.24.15:015][ 81]LogNetPartialBunch: Warning: OutgoingBunches.Num (270) exceeds reliable threashold (8) but this would overflow the reliable buffer! Consider sending less stuff. Channel: [UActorChannel] Actor: FGConveyorChainSubsystem /Game/FactoryGame/Map/GameLevel01/Persistent_Level.Persistent_Level:PersistentLevel.ConveyorChainSubsystem, Role: 3, RemoteRole: 1 [UChannel] ChIndex: 539, Closing: 0 [UNetConnection] RemoteAddr: 197.91.86.165:62243, Name: IpConnection_2147455887, Driver: GameNetDriver FGDSIpNetDriver_2147482083, IsServer: YES, PC: BP_PlayerController_C_2147455555, Owner: BP_PlayerController_C_2147455555, UniqueId: Steam:2 (ForeignId=[Type=6 Handle=1 RepData=[61AC350301001001])\n" "[2024.12.03-16.24.15:018][ 81]LogNetPartialBunch: Warning: SendBunch: Reliable partial bunch overflows reliable buffer! [UActorChannel] Actor: FGConveyorChainSubsystem /Game/FactoryGame/Map/GameLevel01/Persistent_Level.Persistent_Level:PersistentLevel.ConveyorChainSubsystem, Role: 3, RemoteRole: 1 [UChannel] ChIndex: 539, Closing: 0 [UNetConnection] RemoteAddr: 197.91.86.165:62243, Name: IpConnection_2147455887, Driver: GameNetDriver FGDSIpNetDriver_2147482083, IsServer: YES, PC: BP_PlayerController_C_2147455555, Owner: BP_PlayerController_C_2147455555, UniqueId: Steam:2 (ForeignId=[Type=6 Handle=1 RepData=[61AC350301001001])\n" "[2024.12.03-16.24.15:019][ 81]LogNetPartialBunch: Warning: Num OutgoingBunches: 270. NumOutRec: 0\n" "[2024.12.03-16.24.15:019][ 81]LogNet: UNetConnection::SendCloseReason:\n" "[2024.12.03-16.24.15:019][ 81]LogNet: - Result=ReliableBufferOverflow, ErrorContext=\"ReliableBufferOverflow\"\n" "[2024.12\n") matches = re.finditer(regex, test_str, re.MULTILINE) for matchNum, match in enumerate(matches, start=1): print ("Match {matchNum} was found at {start}-{end}: {match}".format(matchNum = matchNum, start = match.start(), end = match.end(), match = match.group())) for groupNum in range(0, len(match.groups())): groupNum = groupNum + 1 print ("Group {groupNum} found at {start}-{end}: {group}".format(groupNum = groupNum, start = match.start(groupNum), end = match.end(groupNum), group = match.group(groupNum))) # Note: for Python 2.7 compatibility, use ur"" to prefix the regex and u"" to prefix the test string and 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 Python, please visit: https://docs.python.org/3/library/re.html