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

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

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 PHP, please visit: http://php.net/manual/en/ref.pcre.php