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

/
/
mg

Test String

Code Generator

Generated Code

// include the latest version of the regex crate in your Cargo.toml extern crate regex; use regex::Regex; fn main() { let regex = Regex::new(r"(?m)^\s(?P<ValueType>\w+)\s(?P<DataType>\w+)?\s?Instance[\.\:](?P<Inheritance>\w+) ?(?P<TagsOrArguments>.+)?").unwrap(); let string = "Class Instance [notbrowsable] Property bool Instance.Archivable Property string Instance.ClassName [readonly] Property int Instance.DataCost [readonly] [RobloxPlaceSecurity] Property string Instance.Name Property Object Instance.Parent Property bool Instance.RobloxLocked [PluginSecurity] Property bool Instance.archivable [hidden] Property string Instance.className [deprecated] [readonly] Function void Instance:ClearAllChildren() Function Instance Instance:Clone() Function void Instance:Destroy() Function Instance Instance:FindFirstChild(string name, bool recursive = false) Function Objects Instance:GetChildren() Function string Instance:GetDebugId(int scopeLength = 4) [notbrowsable] [PluginSecurity] Function string Instance:GetFullName() Function bool Instance:IsA(string className) Function bool Instance:IsAncestorOf(Instance descendant) Function bool Instance:IsDescendantOf(Instance ancestor) Function void Instance:Remove() [deprecated] Function Objects Instance:children() [deprecated] Function Instance Instance:clone() [deprecated] Function void Instance:destroy() [deprecated] Function Instance Instance:findFirstChild(string name, bool recursive = false) [deprecated] Function Objects Instance:getChildren() [deprecated] Function bool Instance:isA(string className) [deprecated] Function bool Instance:isDescendantOf(Instance ancestor) [deprecated] Function void Instance:remove() [deprecated] YieldFunction Instance Instance:WaitForChild(string childName) Event Instance.AncestryChanged(Instance child, Instance parent) Event Instance.Changed(Property property) Event Instance.ChildAdded(Instance child) Event Instance.ChildRemoved(Instance child) Event Instance.DescendantAdded(Instance descendant) Event Instance.DescendantRemoving(Instance descendant) Event Instance.childAdded(Instance child) [deprecated] Class Accoutrement : Instance Property Vector3 Accoutrement.AttachmentForward Property CoordinateFrame Accoutrement.AttachmentPoint Property Vector3 Accoutrement.AttachmentPos Property Vector3 Accoutrement.AttachmentRight Property Vector3 Accoutrement.AttachmentUp Class Hat : Accoutrement Class AdService : Instance [notCreatable] Function void AdService:ShowVideoAd() Event AdService.VideoAdClosed() Class AdvancedDragger : Instance Class Animation : Instance Property Content Animation.AnimationId Class AnimationController : Instance Function Array AnimationController:GetPlayingAnimationTracks() Function Instance AnimationController:LoadAnimation(Instance animation) Event AnimationController.AnimationPlayed(Instance animationTrack) Class AnimationTrack : Instance Property Object AnimationTrack.Animation [readonly] Property bool AnimationTrack.IsPlaying [readonly] Property float AnimationTrack.Length [readonly] Property AnimationPriority AnimationTrack.Priority Property float AnimationTrack.TimePosition Function void AnimationTrack:AdjustSpeed(float speed = 1) Function void AnimationTrack:AdjustWeight(float weight = 1, float fadeTime = 0.100000001) Function double AnimationTrack:GetTimeOfKeyframe(string keyframeName) Function void AnimationTrack:Play(float fadeTime = 0.100000001, float weight = 1, float speed = 1) Function void AnimationTrack:Stop(float fadeTime = 0.100000001) Event AnimationTrack.KeyframeReached(string keyframeName) Event AnimationTrack.Stopped() [deprecated] Class AnimationTrackState : Instance Class Animator : Instance Function Instance Animator:LoadAnimation(Instance animation) Class AssetService : Instance Function void AssetService:SetAssetRevertUrl(string revertUrl) [LocalUserSecurity] Function void AssetService:SetAssetVersionsUrl(string versionsUrl) [LocalUserSecurity] Function void AssetService:SetPlaceAccessUrl(string accessUrl) [LocalUserSecurity] YieldFunction int AssetService:CreatePlaceAsync(string placeName, int templatePlaceID, string description = ) YieldFunction int AssetService:CreatePlaceInPlayerInventoryAsync(Instance player, string placeName, int templatePlaceID, string description = ) YieldFunction Dictionary AssetService:GetAssetVersions(int placeId, int pageNum = 1) YieldFunction int AssetService:GetCreatorAssetID(int creationID) YieldFunction Instance AssetService:GetGamePlacesAsync() YieldFunction Dictionary AssetService:GetPlacePermissions(int placeId) YieldFunction bool AssetService:RevertAsset(int placeId, int versionNumber) YieldFunction void AssetService:SavePlaceAsync() YieldFunction bool AssetService:SetPlacePermissions(int placeId, AccessType accessType = Everyone, Array inviteList = {}) Class BadgeService : Instance [notCreatable] Function void BadgeService:SetAwardBadgeUrl(string url) [LocalUserSecurity] Function void BadgeService:SetHasBadgeCooldown(int seconds) [LocalUserSecurity] Function void BadgeService:SetHasBadgeUrl(string url) [LocalUserSecurity] Function void BadgeService:SetIsBadgeDisabledUrl(string url) [LocalUserSecurity] Function void BadgeService:SetIsBadgeLegalUrl(string url) [LocalUserSecurity] Function void BadgeService:SetPlaceId(int placeId) [LocalUserSecurity] YieldFunction bool BadgeService:AwardBadge(int userId, int badgeId) YieldFunction bool BadgeService:IsDisabled(int badgeId) YieldFunction bool BadgeService:IsLegal(int badgeId) YieldFunction bool BadgeService:UserHasBadge(int userId, int badgeId) Event BadgeService.BadgeAwarded(string message, int userId, int badgeId) [RobloxScriptSecurity] Class BasePlayerGui : Instance Class CoreGui : BasePlayerGui [notbrowsable] [notCreatable] Property Object CoreGui.SelectionImageObject [RobloxScriptSecurity] Property int CoreGui.Version [readonly] Class PlayerGui : BasePlayerGui [notCreatable] Property Object PlayerGui.SelectionImageObject Function float PlayerGui:GetTopbarTransparency() Function void PlayerGui:SetTopbarTransparency(float transparency) Event PlayerGui.TopbarTransparencyChangedSignal(float transparency) Class StarterGui : BasePlayerGui Property bool StarterGui.ResetPlayerGuiOnSpawn Property bool StarterGui.ShowDevelopmentGui Function bool StarterGui:GetCoreGuiEnabled(CoreGuiType coreGuiType) Function void StarterGui:RegisterGetCore(string parameterName, Function getFunction) [RobloxScriptSecurity] Function void StarterGui:RegisterSetCore(string parameterName, Function setFunction) [RobloxScriptSecurity] Function void StarterGui:SetCore(string parameterName, Variant value) Function void StarterGui:SetCoreGuiEnabled(CoreGuiType coreGuiType, bool enabled) YieldFunction Variant StarterGui:GetCore(string parameterName) Event StarterGui.CoreGuiChangedSignal(CoreGuiType coreGuiType, bool enabled) [RobloxScriptSecurity] Class BinaryStringValue : Instance Class BindableEvent : Instance Function void BindableEvent:Fire(Tuple arguments) Event BindableEvent.Event(Tuple arguments) Class BindableFunction : Instance YieldFunction Tuple BindableFunction:Invoke(Tuple arguments) Callback Tuple BindableFunction.OnInvoke(Tuple arguments) Class BodyMover : Instance Class BodyAngularVelocity : BodyMover Property Vector3 BodyAngularVelocity.AngularVelocity Property Vector3 BodyAngularVelocity.MaxTorque Property float BodyAngularVelocity.P Property Vector3 BodyAngularVelocity.angularvelocity Property Vector3 BodyAngularVelocity.maxTorque Class BodyForce : BodyMover Property Vector3 BodyForce.Force Property Vector3 BodyForce.force Class BodyGyro : BodyMover Property CoordinateFrame BodyGyro.CFrame Property float BodyGyro.D Property Vector3 BodyGyro.MaxTorque Property float BodyGyro.P Property CoordinateFrame BodyGyro.cframe [deprecated] Property Vector3 BodyGyro.maxTorque [deprecated] Class BodyPosition : BodyMover Property float BodyPosition.D Property Vector3 BodyPosition.MaxForce Property float BodyPosition.P Property Vector3 BodyPosition.Position Property Vector3 BodyPosition.maxForce [deprecated] Property Vector3 BodyPosition.position [deprecated] Function Vector3 BodyPosition:GetLastForce() Function Vector3 BodyPosition:lastForce() [deprecated] Event BodyPosition.ReachedTarget() Class BodyThrust : BodyMover Property Vector3 BodyThrust.Force Property Vector3 BodyThrust.Location Property Vector3 BodyThrust.force [deprecated] Property Vector3 BodyThrust.location [deprecated] Class BodyVelocity : BodyMover Property Vector3 BodyVelocity.MaxForce Property float BodyVelocity.P Property Vector3 BodyVelocity.Velocity Property Vector3 BodyVelocity.maxForce [deprecated] Property Vector3 BodyVelocity.velocity [deprecated] Function Vector3 BodyVelocity:GetLastForce() Function Vector3 BodyVelocity:lastForce() Class RocketPropulsion : BodyMover Property float RocketPropulsion.CartoonFactor Property float RocketPropulsion.MaxSpeed Property float RocketPropulsion.MaxThrust Property Vector3 RocketPropulsion.MaxTorque Property Object RocketPropulsion.Target Property Vector3 RocketPropulsion.TargetOffset Property float RocketPropulsion.TargetRadius Property float RocketPropulsion.ThrustD Property float RocketPropulsion.ThrustP Property float RocketPropulsion.TurnD Property float RocketPropulsion.TurnP Function void RocketPropulsion:Abort() Function void RocketPropulsion:Fire() Function void RocketPropulsion:fire() [deprecated] Event RocketPropulsion.ReachedTarget() Class Test : Testing [readonly] [RobloxPlaceSecurity] Property bool Testing.ReadOnlyAndSecure [readonly] [RobloxPlaceSecurity]"; // result will be an iterator over tuples containing the start and end indices for each match in the string let result = regex.captures_iter(string); for mat in result { println!("{:?}", mat); } }

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 Rust, please visit: https://docs.rs/regex/latest/regex/