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

Substitution

Processing...

Code Generator

Generated Code

#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox Local $sRegex = "(?m)([\w_]+)\t([\w_]+)\t([\w_]+)" Local $sString = "albatross_v7 g_coeffExit ExtBandsExitCoeff" & @CRLF & _ "albatross_v7 g_dayFilter ExtDayNotToTrade" & @CRLF & _ "albatross_v7 g_period ExtBandsPeriod" & @CRLF & _ "albatross_v7 g_tradeDuration ExtTimeWindowDuration" & @CRLF & _ "albatross_v7 g_tradeStartTime ExtTimeWindowStart" & @CRLF & _ "double_rsi g_coeffRSIFast ExtCoeffRsiFast" & @CRLF & _ "double_rsi g_dayFilter ExtDayNotToTrade" & @CRLF & _ "double_rsi g_RSIDiffLevel ExtMinRsiDiff" & @CRLF & _ "double_rsi g_RSIPeriod ExtSlowRsiPeriod" & @CRLF & _ "double_rsi g_tradeDuration ExtTimeWindowDuration" & @CRLF & _ "double_rsi g_tradeStartTime ExtTimeWindowStart" & @CRLF & _ "double_rsi g_trend ExtTrendModeFilter" & @CRLF & _ "double_rsi g_volatility ExtVolatilityModeFilter" & @CRLF & _ "double_rsi_h4_ei g_coeffRSIFast ExtCoeffRsiFast" & @CRLF & _ "double_rsi_h4_ei g_dayFilter ExtDayNotToTrade" & @CRLF & _ "double_rsi_h4_ei g_exitParameter ExtExitParameter" & @CRLF & _ "double_rsi_h4_ei g_exitType ExtExitType" & @CRLF & _ "double_rsi_h4_ei g_RSIDiffLevel ExtMinRsiDiff" & @CRLF & _ "double_rsi_h4_ei g_RSIPeriod ExtSlowRsiPeriod" & @CRLF & _ "double_rsi_h4_ei g_tradeDuration ExtTimeWindowDuration" & @CRLF & _ "double_rsi_h4_ei g_tradeStartTime ExtTimeWindowStart" & @CRLF & _ "double_rsi_h4_ei g_trend ExtTrendModeFilter" & @CRLF & _ "double_rsi_h4_ei g_volatility ExtVolatilityModeFilter" & @CRLF & _ "hook g_CoeffExit ExtExitCoeff" & @CRLF & _ "hook g_Cycle ExtCycleModeFilter" & @CRLF & _ "hook g_CycleLevel ExtCycleLevel" & @CRLF & _ "hook g_CyclePeriod ExtCyclePeriod" & @CRLF & _ "hook g_Exit ExtExitType" & @CRLF & _ "hook g_Order ExtOrderMode" & @CRLF & _ "hook g_OrderBar ExtBarsNumber" & @CRLF & _ "hook g_OrderPendingBar ExtOrderDeleteBar" & @CRLF & _ "hook g_RSIPeriod ExtRsiPeriod" & @CRLF & _ "hook g_Setup ExtEntrySetup" & @CRLF & _ "hook g_Threshold ExtRsiThreshold" & @CRLF & _ "hook g_Trend ExtTrendModeFilter" & @CRLF & _ "hook g_TrendPeriod ExtTrendPeriod" & @CRLF & _ "hook g_Volatility ExtVolatilityModeFilter" & @CRLF & _ "hook g_TradeDuration ExtTimeWindowDuration" & @CRLF & _ "hook g_TradeStartTime ExtTimeWindowStart" & @CRLF & _ "metaphor_v5 g_barsNumber ExtBarsNumber" & @CRLF & _ "metaphor_v5 g_coeffBarsExit ExtExitCoeffBars" & @CRLF & _ "metaphor_v5 g_dayFilter ExtDayNotToTrade" & @CRLF & _ "metaphor_v5 g_tradeDuration ExtTimeWindowDuration" & @CRLF & _ "metaphor_v5 g_tradeStartTime ExtTimeWindowStart" & @CRLF & _ "metaphor_v6 g_barsNumber ExtBarsNumber" & @CRLF & _ "metaphor_v6 g_BBKCPeriod ExtBbkcPeriod" & @CRLF & _ "metaphor_v6 g_coeffBarsExit ExtExitCoeffBars" & @CRLF & _ "metaphor_v6 g_dayFilter ExtDayNotToTrade" & @CRLF & _ "metaphor_v6 g_tradeDuration ExtTimeWindowDuration" & @CRLF & _ "metaphor_v6 g_tradeStartTime ExtTimeWindowStart" & @CRLF & _ "metaphor_v6_quick g_barsNumber ExtBarsNumber" & @CRLF & _ "metaphor_v6_quick g_BBKCPeriod ExtBbkcPeriod" & @CRLF & _ "metaphor_v6_quick g_coeffBarsExit ExtExitCoeffBars" & @CRLF & _ "metaphor_v6_quick g_dayFilter ExtDayNotToTrade" & @CRLF & _ "metaphor_v6_quick g_tradeDuration ExtTimeWindowDuration" & @CRLF & _ "metaphor_v6_quick g_tradeStartTime ExtTimeWindowStart" & @CRLF & _ "rsi_snr g_dayFilter ExtDayNotToTrade" & @CRLF & _ "rsi_snr g_RSIPeriod ExtRsiPeriod" & @CRLF & _ "rsi_snr g_SNRLevel ExtSnrLevel" & @CRLF & _ "rsi_snr g_SNRPeriod ExtSnrPeriod" & @CRLF & _ "rsi_snr g_tradeDuration ExtTimeWindowDuration" & @CRLF & _ "rsi_snr g_tradeStartTime ExtTimeWindowStart" & @CRLF & _ "rsi_snr g_trend ExtTrendModeFilter" & @CRLF & _ "rsi_snr g_volatility ExtVolatilityModeFilter" & @CRLF & _ "rsi_snr_h1_ei g_dayFilter ExtDayNotToTrade" & @CRLF & _ "rsi_snr_h1_ei g_exitParameter ExtExitParameter" & @CRLF & _ "rsi_snr_h1_ei g_exitType ExtExitType" & @CRLF & _ "rsi_snr_h1_ei g_RSIPeriod ExtRsiPeriod" & @CRLF & _ "rsi_snr_h1_ei g_SNRLevel ExtSnrLevel" & @CRLF & _ "rsi_snr_h1_ei g_SNRPeriod ExtSnrPeriod" & @CRLF & _ "rsi_snr_h1_ei g_tradeDuration ExtTimeWindowDuration" & @CRLF & _ "rsi_snr_h1_ei g_tradeStartTime ExtTimeWindowStart" & @CRLF & _ "rsi_snr_h1_ei g_trend ExtTrendModeFilter" & @CRLF & _ "rsi_snr_h1_ei g_volatility ExtVolatilityModeFilter" & @CRLF & _ "rush_v2_h1 g_counter ExtEntrySignalCounter" & @CRLF & _ "rush_v2_h1 g_dayFilter ExtDayNotToTrade" & @CRLF & _ "rush_v2_h1 g_exitBar ExtExitBar" & @CRLF & _ "rush_v2_h1 g_tradeDuration ExtTimeWindowDuration" & @CRLF & _ "rush_v2_h1 g_tradeStartTime ExtTimeWindowStart" & @CRLF & _ "super_smoother_ei g_dayFilter ExtDayNotToTrade" & @CRLF & _ "super_smoother_ei g_DiffPeriod ExtRsiPeriodDiff" & @CRLF & _ "super_smoother_ei g_exitParameter ExtExitParameter" & @CRLF & _ "super_smoother_ei g_exitType ExtExitType" & @CRLF & _ "super_smoother_ei g_PeriodFast ExtFastRsiPeriod" & @CRLF & _ "super_smoother_ei g_tradeDuration ExtTimeWindowDuration" & @CRLF & _ "super_smoother_ei g_tradeStartTime ExtTimeWindowStart" & @CRLF & _ "super_smoother_ei g_trend ExtTrendModeFilter" & @CRLF & _ "super_smoother_ei g_volatility ExtVolatilityModeFilter" Local $sSubst = "update t_strategy\n set t_strategy_parameters = replace(t_strategy_parameters, '$2', '$3')\n where t_strategy_ea = '$1' and\n t_strategy_parameters like '%$2%' and\n t_strategy_version = '1.1';" Local $sResult = StringRegExpReplace($sString, $sRegex, $sSubst) MsgBox($MB_SYSTEMMODAL, "Result", $sResult)

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