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

/
/
gm

Test String

Code Generator

Generated Code

#include <StringConstants.au3> ; to declare the Constants of StringRegExp #include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate Local $sRegex = "(?m)[\s]*([\/+\s\w@'\,\.()\-\*\-\>\<\_\"]*)?[\n]*UFUNCTION[(]([\w<>\s\(\)\=\,\"\| ]*|\n]*)[\)]\n\s(virtual)*\s*(static)*\s*(\w+\&?\*?)\s(\w+)[(]([\w<>\s,&\*]*|\n]*)[)][\s]*([const]*)" Local $sString = "// Fill out your copyright notice in the Description page of Project Settings." & @CRLF & _ "" & @CRLF & _ "#pragma once" & @CRLF & _ "" & @CRLF & _ "#include "CoreMinimal.h"" & @CRLF & _ "#include "GM_Stepper.h"" & @CRLF & _ "#include "Kismet/BlueprintFunctionLibrary.h"" & @CRLF & _ "#include "StepperTypes.h"" & @CRLF & _ "#include "Encoder/EncodeData.h"" & @CRLF & _ "#include "Components/TextBlock.h"" & @CRLF & _ "#include "BFL_Stepper.generated.h"" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "/**" & @CRLF & _ " * " & @CRLF & _ " */" & @CRLF & _ "UCLASS()" & @CRLF & _ "class STEPPER_API UBFL_Stepper : public UBlueprintFunctionLibrary" & @CRLF & _ "{" & @CRLF & _ " GENERATED_BODY()" & @CRLF & _ "" & @CRLF & _ "public:" & @CRLF & _ " // Returns a copy of the current rendering LogPacket" & @CRLF & _ " // For use ONLY during render time" & @CRLF & _ " // Will be invalid otherwise" & @CRLF & _ " UFUNCTION(BlueprintPure, Category = "Stepper|Core")" & @CRLF & _ " static FLogPacket& GetCurrentLogPacket(bool& Success);" & @CRLF & _ "" & @CRLF & _ " // Updates the log packet sources in memory" & @CRLF & _ " UFUNCTION(BlueprintCallable, Category = "Stepper|Core")" & @CRLF & _ " static bool UpdatePacket(FLogPacket NewPacket);" & @CRLF & _ "" & @CRLF & _ " // Returns a copy of the requested MetaData from the relevant core" & @CRLF & _ " UFUNCTION(BlueprintPure, Category = "Stepper|Core")" & @CRLF & _ " static FGenericMetaTag GetMetaTag(FLogPacket ReferencePacket, FName MetaTag, bool& bIsValid);" & @CRLF & _ " " & @CRLF & _ " // Returns a copy of the requested MetaData from the supplied packet" & @CRLF & _ " UFUNCTION(BlueprintPure, Category = "Stepper|Core")" & @CRLF & _ " static FGenericMetaTag GetMetaTag_Explicit(FLogPacket ReferencePacket, FName MetaTag, bool& bIsValid);" & @CRLF & _ "" & @CRLF & _ " // Returns a logLine for this LogPacket by a LineId" & @CRLF & _ " UFUNCTION(BlueprintPure, Category = "Stepper|Core")" & @CRLF & _ " static bool GetLogLineInId(FLogPacket ReferencePacket, int32 inId, FActionLine& LineData);" & @CRLF & _ "" & @CRLF & _ " // Returns a logLine for this LogPacket by seeking from a specific line" & @CRLF & _ " UFUNCTION(BlueprintPure, Category = "Stepper|Core")" & @CRLF & _ " static bool GetNextActionByType(FLogPacket ReferencePacket, FAction RefAction, FName NextActionName, bool bShouldDebug, FActionLine& Action);" & @CRLF & _ " " & @CRLF & _ " // Updates the LogPacket in memory and text file " & @CRLF & _ " UFUNCTION(BlueprintCallable, Category = "Stepper|Core")" & @CRLF & _ " static void UpdateGenericTag(FLogPacket ReferencePacket, FGenericMetaTag MetaTag);" & @CRLF & _ "" & @CRLF & _ " // Get the saved user settings" & @CRLF & _ " UFUNCTION(BlueprintPure, Category = "Stepper|User Settings")" & @CRLF & _ " static bool GetUserSettings(FUserSettings& Settings);" & @CRLF & _ "" & @CRLF & _ " // Get the saved capture resolution" & @CRLF & _ " UFUNCTION(BlueprintPure, Category = "Stepper|User Settings")" & @CRLF & _ " static FIntPoint GetCaptureResolution();" & @CRLF & _ "" & @CRLF & _ " // Get the saved output resolution" & @CRLF & _ " UFUNCTION(BlueprintPure, Category = "Stepper|User Settings")" & @CRLF & _ " static FIntPoint GetOutputResolution();" & @CRLF & _ "" & @CRLF & _ " // Get the root output folder for this log" & @CRLF & _ " UFUNCTION(BlueprintPure, Category = "Stepper|User Settings")" & @CRLF & _ " static FString GetLogOutputFolder();" & @CRLF & _ "" & @CRLF & _ " // Gets the saved resources folder" & @CRLF & _ " UFUNCTION(BlueprintPure, Category = "Stepper|User Settings")" & @CRLF & _ " static FString GetResourcesFolder();" & @CRLF & _ "" & @CRLF & _ " // Get a reference to the active UStepperObject" & @CRLF & _ " // Can be nullptr" & @CRLF & _ " UFUNCTION(BlueprintPure, Category = "Stepper|Statics")" & @CRLF & _ " static UStepperCore* GetStepper();" & @CRLF & _ "" & @CRLF & _ " // Get the currently rendered stepper frame number" & @CRLF & _ " // Return -1 if not rendering" & @CRLF & _ " UFUNCTION(BlueprintPure, Category = "Stepper|Statics")" & @CRLF & _ " static int32 GetStepperFrame();" & @CRLF & _ "" & @CRLF & _ " // Checks if a file is of type "png", "jpg", "mp4" or "mov"" & @CRLF & _ " UFUNCTION(BlueprintPure)" & @CRLF & _ " static bool bIsMediaFile(FString FileName);" & @CRLF & _ "" & @CRLF & _ " // Get the language of the inputted log packet" & @CRLF & _ " UFUNCTION(BlueprintPure)" & @CRLF & _ " static FString GetLogLanguage(FLogPacket LogPacket);" & @CRLF & _ "" & @CRLF & _ " // Get the packet's framerate" & @CRLF & _ " UFUNCTION(BlueprintPure, meta=(CompactNodeTitle="FR", Keywords = "FrameRate, Frame, Rate"))" & @CRLF & _ " static FFrameRate GetPacketFrameRate(FLogPacket Packet);" & @CRLF & _ " // Get the rendered framerate" & @CRLF & _ " UFUNCTION(BlueprintPure, meta=(CompactNodeTitle="FR", Keywords = "FrameRate, Frame, Rate"))" & @CRLF & _ " static bool GetRenderedFrameRate(FFrameRate& FrameRate);" & @CRLF & _ " // Get the packet's start timecode" & @CRLF & _ " UFUNCTION(BlueprintPure, meta=(CompactNodeTitle="STC", Keywords = "Timecode, Time, Code, TC"))" & @CRLF & _ " static FTimecode GetPacketStartTimecode(FLogPacket Packet);" & @CRLF & _ " // Get the packet's end timecode" & @CRLF & _ " UFUNCTION(BlueprintPure, meta=(CompactNodeTitle="ETC", Keywords = "Timecode, Time, Code, TC"))" & @CRLF & _ " static FTimecode GetPacketEndTimecode(FLogPacket Packet);" & @CRLF & _ " //Get the timecode data struct from the currently loaded LogPackt's MetaData" & @CRLF & _ " UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Stepper|XML|Helpers")" & @CRLF & _ " static FTimecodeData GetPacketTimecodeData(FLogPacket Packet);" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ " UFUNCTION()" & @CRLF & _ " static bool bIsDllLoaded(FString DllName);" & @CRLF & _ "" & @CRLF & _ " // Get a reference to the active game mode" & @CRLF & _ " UFUNCTION(BlueprintCallable)" & @CRLF & _ " static AGM_Stepper* GetGameMode();" & @CRLF & _ "" & @CRLF & _ " UFUNCTION()" & @CRLF & _ " static ELogRenderStatus QtChangeFile(FLogPacket& LogPacket, FCameraData& CameraData, int32 Iteration);" & @CRLF & _ " UFUNCTION()" & @CRLF & _ " static ELogRenderStatus QtChangeFile_Scatter(FLogPacket& LogPacket, FCameraData& CameraData, int32 ScatterIndex, FName ScatterTag, FTimecode ClipTc, int32 Iteration);" & @CRLF & _ " UFUNCTION()" & @CRLF & _ " static ELogRenderStatus RunQtBat(FString BatLoc, FString Dir);" & @CRLF & _ "" & @CRLF & _ " UFUNCTION()" & @CRLF & _ " static int CheckLine(FString Line);" & @CRLF & _ " // Break a TextBox's text into lines" & @CRLF & _ " UFUNCTION(BlueprintCallable)" & @CRLF & _ " static void BreakTextBox(UTextBlock* TextBox, int32 MaxLineSize);" & @CRLF & _ "" & @CRLF & _ " //Takes a snapshot of a widget and returns it as a render target" & @CRLF & _ " UFUNCTION(BlueprintCallable, Category = "Stepper|Helpers", meta=(DisplayName="Render Target From Widget With Alpha"))" & @CRLF & _ " static UTextureRenderTarget2D* RtFromWidget_Alpha(UUserWidget* const Widget, FVector2D Size);" & @CRLF & _ "" & @CRLF & _ " //Adds a prefix 0 for numbers below 10 (i.e 6 -> 06)" & @CRLF & _ " UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Stepper|Helpers")" & @CRLF & _ " static void IntToPaddedString(int32 Int, FString& PaddedString);" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ " " & @CRLF & _ "};" & @CRLF & _ "" Local $aArray = StringRegExp($sString, $sRegex, $STR_REGEXPARRAYGLOBALFULLMATCH) Local $aFullArray[0] For $i = 0 To UBound($aArray) -1 _ArrayConcatenate($aFullArray, $aArray[$i]) Next $aArray = $aFullArray ; Present the entire match result _ArrayDisplay($aArray, "Result")

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 AutoIt, please visit: https://www.autoitscript.com/autoit3/docs/functions/StringRegExp.htm