Regular Expressions 101

Save & Share

  • Regex Version: ver. 1
  • 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

/
/
gms

Test String

Code Generator

Generated Code

$re = '/DbFileInput\.DbFileInput.*<Query>(.*?)<\/Query>/ms'; $str = '<?xml version="1.0"?> <AlteryxDocument yxmdVer="2023.2" RunE2="T"> <Nodes> <Node ToolID="1"> <GuiSettings Plugin="AlteryxBasePluginsGui.DbFileInput.DbFileInput"> <Position x="246" y="222" /> </GuiSettings> <Properties> <Configuration> <Passwords /> <File /> <FormatSpecificOptions UseDcm="true" Format="23" RecordLimit=""> <Query>select * from "XXXX_01"."PUBLIC"."CASES_GB"</Query> <TableStyle>Quoted</TableStyle> <CacheData>False</CacheData> <Table /> <SessionReadOnly>True</SessionReadOnly> <ReadUncommitted>False</ReadUncommitted> <Connection DcmType="ConnectionId">829c98d7-4345-4f8a-98fe-ea278c707529</Connection> <NoProgress>True</NoProgress> <PostSQL /> <PreSQLOnConfig>True</PreSQLOnConfig> <PreSQL /> </FormatSpecificOptions> </Configuration> <Annotation DisplayMode="0"> <Name /> <DefaultAnnotationText>dcm:Snowflake — fmv_cred Query=select * from "XXXXX"....</DefaultAnnotationText> <Left value="False" /> </Annotation> <MetaInfo connection="Output"> <RecordInfo> <Field name="claimnumber" size="2048" source="File: select * &#xA;from &quot;MEDSOL_01&quot;.&quot;PUBLIC&quot;.&quot;CASES_GB&quot;" type="V_WString" /> <Field name="chartno" size="2048" source="File: select * &#xA;from &quot;MEDSOL_01&quot;.&quot;PUBLIC&quot;.&quot;CASES_GB&quot;" type="V_WString" /> <Field name="billnumber" size="2048" source="File: select * &#xA;from &quot;MEDSOL_01&quot;.&quot;PUBLIC&quot;.&quot;CASES_GB&quot;" type="V_WString" /> <Field name="account" size="2048" source="File: select * &#xA;from &quot;MEDSOL_01&quot;.&quot;PUBLIC&quot;.&quot;CASES_GB&quot;" type="V_WString" /> <Field name="date" source="File: select * &#xA;from &quot;MEDSOL_01&quot;.&quot;PUBLIC&quot;.&quot;CASES_GB&quot;" type="Date" /> <Field name="caseno" size="2048" source="File: select * &#xA;from &quot;MEDSOL_01&quot;.&quot;PUBLIC&quot;.&quot;CASES_GB&quot;" type="V_WString" /> <Field name="caseid" size="2048" source="File: select * &#xA;from &quot;MEDSOL_01&quot;.&quot;PUBLIC&quot;.&quot;CASES_GB&quot;" type="V_WString" /> <Field name="patientname" size="2048" source="File: select * &#xA;from &quot;MEDSOL_01&quot;.&quot;PUBLIC&quot;.&quot;CASES_GB&quot;" type="V_WString" /> <Field name="dob" source="File: select * &#xA;from &quot;MEDSOL_01&quot;.&quot;PUBLIC&quot;.&quot;CASES_GB&quot;" type="Date" /> <Field name="patientphone" size="2048" source="File: select * &#xA;from &quot;MEDSOL_01&quot;.&quot;PUBLIC&quot;.&quot;CASES_GB&quot;" type="V_WString" /> <Field name="policyholder" size="2048" source="File: select * &#xA;from &quot;MEDSOL_01&quot;.&quot;PUBLIC&quot;.&quot;CASES_GB&quot;" type="V_WString" /> <Field name="policynumber" size="2048" source="File: select * &#xA;from &quot;MEDSOL_01&quot;.&quot;PUBLIC&quot;.&quot;CASES_GB&quot;" type="V_WString" /> <Field name="insurancename" size="2048" source="File: select * &#xA;from &quot;MEDSOL_01&quot;.&quot;PUBLIC&quot;.&quot;CASES_GB&quot;" type="V_WString" /> <Field name="casetypename" size="2048" source="File: select * &#xA;from &quot;MEDSOL_01&quot;.&quot;PUBLIC&quot;.&quot;CASES_GB&quot;" type="V_WString" /> <Field name="doa" source="File: select * &#xA;from &quot;MEDSOL_01&quot;.&quot;PUBLIC&quot;.&quot;CASES_GB&quot;" type="Date" /> <Field name="specialty" size="2048" source="File: select * &#xA;from &quot;MEDSOL_01&quot;.&quot;PUBLIC&quot;.&quot;CASES_GB&quot;" type="V_WString" /> <Field name="provider" size="2048" source="File: select * &#xA;from &quot;MEDSOL_01&quot;.&quot;PUBLIC&quot;.&quot;CASES_GB&quot;" type="V_WString" /> <Field name="billamount" source="File: select * &#xA;from &quot;MEDSOL_01&quot;.&quot;PUBLIC&quot;.&quot;CASES_GB&quot;" type="Double" /> <Field name="paid" source="File: select * &#xA;from &quot;MEDSOL_01&quot;.&quot;PUBLIC&quot;.&quot;CASES_GB&quot;" type="Double" /> <Field name="balance" source="File: select * &#xA;from &quot;MEDSOL_01&quot;.&quot;PUBLIC&quot;.&quot;CASES_GB&quot;" type="Double" /> <Field name="firstvisitdate" source="File: select * &#xA;from &quot;MEDSOL_01&quot;.&quot;PUBLIC&quot;.&quot;CASES_GB&quot;" type="Date" /> <Field name="lastvisitdate" source="File: select * &#xA;from &quot;MEDSOL_01&quot;.&quot;PUBLIC&quot;.&quot;CASES_GB&quot;" type="Date" /> <Field name="dos" size="2048" source="File: select * &#xA;from &quot;MEDSOL_01&quot;.&quot;PUBLIC&quot;.&quot;CASES_GB&quot;" type="V_WString" /> <Field name="days" scale="0" size="21" source="File: select * &#xA;from &quot;MEDSOL_01&quot;.&quot;PUBLIC&quot;.&quot;CASES_GB&quot;" type="FixedDecimal" /> <Field name="billdate" source="File: select * &#xA;from &quot;MEDSOL_01&quot;.&quot;PUBLIC&quot;.&quot;CASES_GB&quot;" type="Date" /> <Field name="status" size="2048" source="File: select * &#xA;from &quot;MEDSOL_01&quot;.&quot;PUBLIC&quot;.&quot;CASES_GB&quot;" type="V_WString" /> <Field name="username" size="2048" source="File: select * &#xA;from &quot;MEDSOL_01&quot;.&quot;PUBLIC&quot;.&quot;CASES_GB&quot;" type="V_WString" /> <Field name="doctor" size="2048" source="File: select * &#xA;from &quot;MEDSOL_01&quot;.&quot;PUBLIC&quot;.&quot;CASES_GB&quot;" type="V_WString" /> <Field name="readingdoctor" size="2048" source="File: select * &#xA;from &quot;MEDSOL_01&quot;.&quot;PUBLIC&quot;.&quot;CASES_GB&quot;" type="V_WString" /> <Field name="doctorlocation" size="2048" source="File: select * &#xA;from &quot;MEDSOL_01&quot;.&quot;PUBLIC&quot;.&quot;CASES_GB&quot;" type="V_WString" /> <Field name="pomid" size="2048" source="File: select * &#xA;from &quot;MEDSOL_01&quot;.&quot;PUBLIC&quot;.&quot;CASES_GB&quot;" type="V_WString" /> <Field name="noofvisits" scale="0" size="21" source="File: select * &#xA;from &quot;MEDSOL_01&quot;.&quot;PUBLIC&quot;.&quot;CASES_GB&quot;" type="FixedDecimal" /> <Field name="pomgenerateddate" source="File: select * &#xA;from &quot;MEDSOL_01&quot;.&quot;PUBLIC&quot;.&quot;CASES_GB&quot;" type="Date" /> <Field name="pomstampeddateone" size="2048" source="File: select * &#xA;from &quot;MEDSOL_01&quot;.&quot;PUBLIC&quot;.&quot;CASES_GB&quot;" type="V_WString" /> <Field name="billnote" size="2048" source="File: select * &#xA;from &quot;MEDSOL_01&quot;.&quot;PUBLIC&quot;.&quot;CASES_GB&quot;" type="V_WString" /> <Field name="referringdoctor" size="2048" source="File: select * &#xA;from &quot;MEDSOL_01&quot;.&quot;PUBLIC&quot;.&quot;CASES_GB&quot;" type="V_WString" /> <Field name="pomstampeddate" source="File: select * &#xA;from &quot;MEDSOL_01&quot;.&quot;PUBLIC&quot;.&quot;CASES_GB&quot;" type="Date" /> <Field name="billingaddress" size="2048" source="File: select * &#xA;from &quot;MEDSOL_01&quot;.&quot;PUBLIC&quot;.&quot;CASES_GB&quot;" type="V_WString" /> <Field name="treatingdoctor_0_doctorname" size="2048" source="File: select * &#xA;from &quot;MEDSOL_01&quot;.&quot;PUBLIC&quot;.&quot;CASES_GB&quot;" type="V_WString" /> <Field name="treatingdoctor_0_npi" size="2048" source="File: select * &#xA;from &quot;MEDSOL_01&quot;.&quot;PUBLIC&quot;.&quot;CASES_GB&quot;" type="V_WString" /> </RecordInfo> </MetaInfo> </Properties> <EngineSettings EngineDll="AlteryxBasePluginsEngine.dll" EngineDllEntryPoint="AlteryxDbFileInput" /> </Node> <Node ToolID="2"> <GuiSettings Plugin="AlteryxBasePluginsGui.BrowseV2.BrowseV2"> <Position x="366" y="222" /> </GuiSettings> <Properties> <Configuration /> <Annotation DisplayMode="0"> <Name /> <DefaultAnnotationText /> <Left value="False" /> </Annotation> </Properties> <EngineSettings EngineDll="AlteryxBasePluginsEngine.dll" EngineDllEntryPoint="AlteryxBrowseV2" /> </Node> </Nodes> <Connections> <Connection> <Origin ToolID="1" Connection="Output" /> <Destination ToolID="2" Connection="Input" /> </Connection> </Connections> <Properties> <Memory default="True" /> <GlobalRecordLimit value="0" /> <TempFiles default="True" /> <Annotation on="True" includeToolName="False" /> <ConvErrorLimit value="10" /> <ConvErrorLimit_Stop value="False" /> <CancelOnError value="False" /> <DisableBrowse value="False" /> <EnablePerformanceProfiling value="False" /> <RunWithE2 value="True" /> <SortedGrouping value="True" /> <PredictiveToolsCodePage value="1252" /> <DisableAllOutput value="False" /> <ShowAllMacroMessages value="False" /> <ShowConnectionStatusIsOn value="True" /> <ShowConnectionStatusOnlyWhenRunning value="False" /> <ZoomLevel value="0" /> <LayoutType>Horizontal</LayoutType> <MetaInfo> <NameIsFileName value="True" /> <Name>Test</Name> <Description /> <RootToolName /> <ToolVersion /> <ToolInDb value="False" /> <CategoryName /> <SearchTags /> <Author /> <Company /> <Copyright /> <DescriptionLink actual="" displayed="" /> <Example> <Description /> <File /> </Example> <WorkflowId value="6d029b0d-30da-40ad-819f-0d8b2dd496cb" /> <Telemetry> <PreviousWorkflowId value="2fab71ce-8734-4c9a-9f05-e9279b77b7a8" /> <OriginWorkflowId value="2fab71ce-8734-4c9a-9f05-e9279b77b7a8" /> </Telemetry> <PlatformWorkflowId value="" /> </MetaInfo> <Events> <Enabled value="True" /> </Events> </Properties> </AlteryxDocument>'; 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