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

/
/
gmix

Test String

Code Generator

Generated Code

$re = '/(?<i_cl>insert (?: \s (?: into | bulk ))?) \s (?(?=openquery) (?: (?<i_oq>openquery) \s \( (?<i_oq_srv>\S+) \, \s \' .*? \'\) ) | (?: (?<i_tbl>\S+) ) ) .*? \s select \s .*? (?: (?<f_cl>from) \s (?(?=openquery) (?: (?<f_oq>openquery) \s \( (?<f_oq_srv>\S+) \, \s \' (?: .+? (?<f_oq_cl>from|join) \s (?<f_oq_tbl>\S+) ) .* \'\) ) | (?: (?<f_tbl>\S+) ) ) )+/mix'; $str = ' insert openquery (datadata_adm, \'SELECT MOTONADPIS_ID, CALCDATE, POPA_ID, POPA_BUMP, PICT_ID, PICT_BUMP, KOL_NADPIS, OST_PERIOD_EXPIRE, FERMATA_DD, FERMATA_HM, FERMATA_DK, MAX_SHT_VSE_MX, MAX_SHT_3_BLOCK_MX, OPRONUDITELNO, DAYS_COUNT, DECOCIATOR, USERNAME, Name_p_ROSP, Tip_rascheta, ID_PIGISTER FROM ZOLA.T_MOTONADPIS_PERMALATE\') SELECT t.[MOTONADPIS_ID], cast ([CALCDATE] as date), c.T_POPA_ID, [POPA_BUMP], a.t_PICT_id, [PICT_BUMP], [KOL_NADPIS], case when [OST_PERIOD_EXPIRE]=\'\' then null else [OST_PERIOD_EXPIRE] end as [OST_PERIOD_EXPIRE], [FERMATA_DD], [FERMATA_HM], [FERMATA_DK], [MAX_SHT_VSE_MX], [MAX_SHT_3_BLOCK_MX], [OPRONUDITELNO], [DAYS_COUNT], [DECOCIATOR], [USERNAME], [Name_p_ROSP], [Tip_rascheta], w.ID_PIGISTER FROM [ZOLA].[bodo].[T_MOTONADPIS_PERMAlate_N] t join SOURCE..T_POPA c on c.O_POPA_BUMP=t.POPA_BUMP join SOURCE..t_PICT a on a.T_PICT_BUMP=t.PICT_BUMP left join ZOLA..T_MOTONADPIS_Web_Document_Links w on w.MOTONADPIS_ID=t.MOTONADPIS_ID where t.[MOTONADPIS_ID]=@MOTORO insert bulk dbVHS..T_GIST select t2.ClDECOqueIDRow_AL, t2.ID_CUMMI, t2.ID_PIGISTER, t2.RN, t2.IS_TRANSMITTED, t1.STATUS_ID, t1.ErrorMSG, t2.USERNAME, t2.ID_POPA, t2.ID_WS, t2.ID_PICT, t2.ID_GRP_PICT_LVL0, t2.ID_GRP_PICT_LVL1, t2.ID_GRP_PICT_LVL2, t2.ID_GRP_PICT_LVL3, t2.ASTNAME, t2.QUANT, t2.PERC, t2.BDATE, t2.EDATE, t2.PICTSET_TYPE, t2.FUCKTION, t2.DESCRIPT, t2.ID_ADAPTER, getdate () as END_TIME from ..T_AST_CUMMI_WORK_RESULT t1 join ..T_PROCESS_PERMA t2 on t1.ClDECOqueIDRow = t2.ClDECOqueIDRow_AL left join ..T_GIST t3 on t1.ClDECOqueIDRow = t3.ClDECOqueIDRow_AL and t2.ID_CUMMI = t3.ID_CUMMI where t3.ClDECOqueIDRow_AL is null insert into ..T_GIST (v1, v2, v3) select t2.ClDECOqueIDRow_AL, t2.ID_CUMMI, t2.ID_PIGISTER, t2.RN, t2.IS_TRANSMITTED, t1.STATUS_ID, t1.ErrorMSG, t2.USERNAME, t2.ID_POPA, t2.ID_WS, t2.ID_PICT, t2.ID_GRP_PICT_LVL0, t2.ID_GRP_PICT_LVL1, t2.ID_GRP_PICT_LVL2, t2.ID_GRP_PICT_LVL3, t2.ASTNAME, t2.QUANT, t2.PERC, t2.BDATE, t2.EDATE, t2.PICTSET_TYPE, t2.FUCKTION, t2.DESCRIPT, t2.ID_ADAPTER, getdate () as END_TIME from ..T_AST_CUMMI_WORK_RESULT t1, Cross..join tc join ..T_PROCESS_PERMA t2 on t1.ClDECOqueIDRow = t2.ClDECOqueIDRow_AL left join ..T_GIST t3 on t1.ClDECOqueIDRow = t3.ClDECOqueIDRow_AL and t2.ID_CUMMI = t3.ID_CUMMI where t3.ClDECOqueIDRow_AL is null insert into ..T_LOH_2 select getdate (), ID_CUMMI, 7, count (1), 11, count (case when PROCESS_STATUS = 2 then 1 else null end), ID_PIGISTER, USERNAME from #TMP_DELETE group by ID_CUMMI, ID_PIGISTER, USERNAME insert into ..T_GIST.[zjopa] select t2.ClDECOqueIDRow_AL, t2.ID_CUMMI, t2.ID_PIGISTER, t2.RN, t2.IS_TRANSMITTED, t1.STATUS_ID, t1.ErrorMSG, t2.USERNAME, t2.ID_POPA, t2.ID_WS, t2.ID_PICT, t2.ID_GRP_PICT_LVL0, t2.ID_GRP_PICT_LVL1, t2.ID_GRP_PICT_LVL2, t2.ID_GRP_PICT_LVL3, t2.ASTNAME, t2.QUANT, t2.PERC, t2.BDATE, t2.EDATE, t2.PICTSET_TYPE, t2.FUCKTION, t2.DESCRIPT, t2.ID_ADAPTER, getdate () as END_TIME from ..T_AST_CUMMI_WORK_RESULT join ..T_PROCESS_PERMA t2 on t1.ClDECOqueIDRow = t2.ClDECOqueIDRow_AL left join ..T_GIST t3 on t1.ClDECOqueIDRow = t3.ClDECOqueIDRow_AL and t2.ID_CUMMI = t3.ID_CUMMI where t3.ClDECOqueIDRow_AL is null insert into ..T_GIST select t2.ClDECOqueIDRow_AL, t2.ID_CUMMI, t2.ID_PIGISTER, t2.RN, t2.IS_TRANSMITTED, t1.STATUS_ID, t1.ErrorMSG, t2.USERNAME, t2.ID_POPA, t2.ID_WS, t2.ID_PICT, t2.ID_GRP_PICT_LVL0, t2.ID_GRP_PICT_LVL1, t2.ID_GRP_PICT_LVL2, t2.ID_GRP_PICT_LVL3, t2.ASTNAME, t2.QUANT, t2.PERC, t2.BDATE, t2.EDATE, t2.PICTSET_TYPE, t2.FUCKTION, t2.DESCRIPT, t2.ID_ADAPTER, getdate () as END_TIME from openquery (tera_serv, \'select from ..T_AST_CUMMI_WORK_RESULT t1 join ..T_PROCESS_PERMA t2 on t1.ClDECOqueIDRow = t2.ClDECOqueIDRow_AL left join ..T_GIST t3 on t1.ClDECOqueIDRow = t3.ClDECOqueIDRow_AL and t2.ID_CUMMI = t3.ID_CUMMI where t3.ClDECOqueIDRow_AL is null\') join abc..abd'; 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