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
No Match

/
/
g

Test String

Substitution

Processing...

Code Generator

Generated Code

const regex = /(<tspan .*?>)(.*?)(<\/tspan>)/g; // Alternative syntax using RegExp constructor // const regex = new RegExp('(<tspan .*?>)(.*?)(<\\\/tspan>)', 'g') const str = `<?xml version="1.0" encoding="UTF-8"?> <svg id="svg2" width="10cm" height="16.2cm" version="1.1" viewBox="0 0 354.33 574.02" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <g id="layer1"> <text id="text98" x="154.52208" y="379.77606" fill="#000000" font-family="Arial" font-size="31.17px" letter-spacing="0px" stroke-width="1.1689" text-align="center" text-anchor="middle" word-spacing="0px" style="font-feature-settings:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal;line-height:1.25" xml:space="preserve"><tspan id="tspan96" x="154.52208" y="379.77606" fill="#000000" stroke-width="1.1689">%%DFPH_DESTINATION_NAME%%</tspan></text> <rect id="rect814" x="280.54" y="42.643" width="65.227" height="30.474" fill="none" stroke="#000" stroke-width="1.1707"/> <rect id="rect816" x="263.81" y="153.88" width="43.539" height="41.178" fill="none" stroke="#000" stroke-width="1.1707"/> <rect id="rect818" x="129.94" y="191.18" width="87.201" height="29.771" ry="0" fill="none" stroke="#000" stroke-width="1.1537"/> <rect id="rect822" x="130.78" y="259.3" width="39.553" height="21.916" fill="none" stroke="#000" stroke-width="1.1707"/> <rect id="rect824" x="68.677" y="297.25" width="175.46" height="42.932" stroke="#000" stroke-width="1.2456"/> <rect id="rect826" x="68.03" y="347.05" width="175.3" height="43.739" fill="none" stroke="#000" stroke-width="1.4137"/> <rect id="rect828" x="254.46" y="348.43" width="87.205" height="43.027" fill="none" stroke="#000" stroke-width="1.1501"/> <path id="path830" d="m-0.30788 150.64h353.78" fill="none" stroke="#000" stroke-width="2.6639"/> <path id="path832" d="m0.2261 284.76h353.28" fill="none" stroke="#000" stroke-width="2.8117px"/> <path id="path834" d="m58.878 581.12v-297.65" fill="none" stroke="#000" stroke-dasharray="2.36954735, 9.47818949" stroke-width="2.3696"/> <text id="text32" x="331.55414" y="187.3322" fill="#000000" font-family="Arial" font-size="34.287px" font-weight="bold" letter-spacing="0px" stroke-width=".88633" text-align="center" text-anchor="middle" word-spacing="0px" style="font-feature-settings:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal;line-height:1.25" xml:space="preserve"><tspan id="tspan30" x="331.55414" y="187.3322" font-family="Arial" font-size="34.287px" font-weight="bold" stroke-width=".88633" text-align="center" text-anchor="middle" style="font-feature-settings:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal">%AREA%</tspan></text> <text id="text54" x="33.566467" y="167.6949" fill="#000000" font-family="Arial" font-size="14.026px" letter-spacing="0px" stroke-width="1.1689" word-spacing="0px" style="font-feature-settings:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal;line-height:1.25" xml:space="preserve"><tspan id="tspan52" x="33.566467" y="167.6949" font-family="Arial" font-size="14.026px" stroke-width="1.1689" style="font-feature-settings:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal">店配訂單編號:</tspan></text> <text id="text58" x="34.193069" y="181.70798" fill="#000000" font-family="Arial" font-size="14.026px" letter-spacing="0px" stroke-width="1.1689" word-spacing="0px" style="font-feature-settings:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal;line-height:1.25" xml:space="preserve"><tspan id="tspan56" x="34.193069" y="181.70798" font-family="Arial" font-size="14.026px" stroke-width="1.1689" style="font-feature-settings:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal">廠商訂單編號:</tspan></text> <text id="text62" x="130.02902" y="167.56573" fill="#000000" font-family="Arial" font-size="14.026px" letter-spacing="0px" stroke-width="1.1689" word-spacing="0px" style="font-feature-settings:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal;line-height:1.25" xml:space="preserve"><tspan id="tspan60" x="130.02902" y="167.56573" font-family="Arial" font-size="14.026px" stroke-width="1.1689" style="font-feature-settings:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal">%ORDER_NUMBER%</tspan></text> <text id="text66" x="130.02902" y="181.77615" fill="#000000" font-family="Arial" font-size="14.026px" letter-spacing="0px" stroke-width="1.1689" word-spacing="0px" style="font-feature-settings:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal;line-height:1.25" xml:space="preserve"><tspan id="tspan64" x="130.02902" y="181.77615" font-family="Arial" font-size="14.026px" stroke-width="1.1689" style="font-feature-settings:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal">%ORDER_NUMBER%</tspan></text> <text id="text70" x="175.84" y="217.58981" fill="#000000" font-family="Arial" font-size="31.17px" letter-spacing="0px" stroke-width="1.1689" text-align="center" text-anchor="middle" word-spacing="0px" style="font-feature-settings:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal;line-height:1.25" xml:space="preserve"><tspan id="tspan68" x="175.84" y="217.58981" font-family="Arial" font-size="31.17px" stroke-width="1.1689" text-align="center" text-anchor="middle" style="font-feature-settings:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal">%EQUIPMENT_ID%</tspan></text> <rect id="RoutingStepCodeBoxWhite" x="129.94" y="226.52" width="87.2" height="29.769" fill="none" stroke="#000" stroke-width="1.1554"/> <rect id="RoutingStepCodeBoxBlack" x="129.94" y="226.52" width="87.2" height="29.769" stroke="#000" stroke-width="1.1554"/> <text id="RoutingStepCodeTextBlack" x="172.18604" y="252.61942" fill="#000000" font-family="Arial" font-size="31.17px" letter-spacing="0px" stroke-width="1.1689" text-align="center" text-anchor="middle" word-spacing="0px" style="font-feature-settings:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal;line-height:1.25" xml:space="preserve"><tspan id="tspan72" x="172.18604" y="252.61942" fill="#000000" stroke-width="1.1689">%ROUTING_STEP_CODE%</tspan></text> <text id="RoutingStepCodeTextWhite" x="172.18555" y="252.62019" fill="#ffffff" font-family="Arial" font-size="31.17px" letter-spacing="0px" stroke-width="1.1689" text-align="center" text-anchor="middle" word-spacing="0px" style="font-feature-settings:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal;line-height:1.25" xml:space="preserve"><tspan id="tspan72-3" x="172.18555" y="252.62019" fill="#ffffff" stroke-width="1.1689">%ROUTING_STEP_CODE%</tspan></text> <text id="text78" x="150.45471" y="275.63907" fill="#000000" font-family="Arial" font-size="15.585px" letter-spacing="0px" stroke-width="1.1689" text-align="center" text-anchor="middle" word-spacing="0px" style="font-feature-settings:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal;line-height:1.25" xml:space="preserve"><tspan id="tspan76" x="150.45471" y="275.63907" font-family="Arial" font-size="15.585px" stroke-width="1.1689" text-align="center" text-anchor="middle" style="font-feature-settings:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal">D13</tspan></text> <text id="text82" x="346.98782" y="275.22568" fill="#000000" font-family="Arial" font-size="14.026px" letter-spacing="0px" stroke-width="1.1689" text-align="end" text-anchor="end" word-spacing="0px" style="font-feature-settings:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal;line-height:1.25" xml:space="preserve"><tspan id="tspan80" x="346.98782" y="275.22568" font-family="Arial" font-size="14.026px" stroke-width="1.1689" text-align="end" text-anchor="end" style="font-feature-settings:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal">176 0001 (日退) 自行取貨</tspan></text> <text id="text86" x="31.811769" y="362.91437" fill="#000000" font-family="Arial" font-size="31.17px" letter-spacing="0px" stroke-width="1.1689" text-align="center" text-anchor="middle" word-spacing="0px" style="font-feature-settings:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal;line-height:1.25" xml:space="preserve"><tspan id="tspan84" x="31.811769" y="362.91437" text-align="center" style="font-feature-settings:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal">取</tspan><tspan id="tspan95" x="31.811769" y="404.48364" text-align="center" style="font-feature-settings:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal">件</tspan><tspan id="tspan97" x="31.811769" y="446.05289" text-align="center" style="font-feature-settings:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal">專</tspan><tspan id="tspan99" x="31.811769" y="487.62216" text-align="center" style="font-feature-settings:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal">用</tspan></text> <text id="text90" x="156.81093" y="328.54968" fill="#ffffff" font-family="Arial" font-size="31.17px" letter-spacing="0px" stroke-width="1.1689" text-align="center" text-anchor="middle" word-spacing="0px" style="font-feature-settings:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal;line-height:1.25" xml:space="preserve"><tspan id="tspan88" x="156.81093" y="328.54968" fill="#ffffff" stroke-width="1.1689">宅配通</tspan></text> <text id="text94" x="301.2027" y="323.10361" fill="#000000" font-family="Arial" font-size="31.17px" letter-spacing="0px" stroke-width="1.1689" word-spacing="0px" style="font-feature-settings:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal;line-height:1.25" xml:space="preserve"><tspan id="tspan92" x="301.2027" y="323.10361" font-family="Arial" font-size="15.585px" stroke-width="1.1689" text-align="center" text-anchor="middle" style="font-feature-settings:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal">%PAYMENT_TYPE%</tspan></text> <text id="text102" x="298.85205" y="363.01605" fill="#000000" font-family="Arial" font-size="12.468px" letter-spacing="0px" stroke-width="1.1689" text-align="center" text-anchor="middle" word-spacing="0px" style="font-feature-settings:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal;line-height:1.25" xml:space="preserve"><tspan id="tspan100" x="298.85205" y="363.01605" font-family="Arial" font-size="12.468px" stroke-width="1.1689" text-align="center" text-anchor="middle" style="font-feature-settings:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal">手機末三碼</tspan></text> <text id="text106" x="296.24631" y="387.81454" fill="#000000" font-family="Arial" font-size="28.053px" letter-spacing="0px" stroke-width="1.1689" text-align="center" text-anchor="middle" word-spacing="0px" style="font-feature-settings:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal;line-height:1.25" xml:space="preserve"><tspan id="tspan104" x="296.24631" y="387.81454" font-family="Arial" font-size="28.053px" stroke-width="1.1689" text-align="center" text-anchor="middle" style="font-feature-settings:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal">%RECEIVER_LAST_3_MOBILE_NUMBER%</tspan></text> <text id="text110" x="204.26619" y="419.82205" fill="#000000" font-family="Arial" font-size="31.17px" letter-spacing="0px" stroke-width="1.1689" text-align="center" text-anchor="middle" word-spacing="0px" style="font-feature-settings:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal;line-height:1.25" xml:space="preserve"><tspan id="tspan108" x="204.26619" y="419.82205" font-family="Arial" font-size="23.377px" stroke-width="1.1689" text-align="center" text-anchor="middle" style="font-feature-settings:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal">%%DFPH_DESTINATION_SHIPPING_DROP_POINT_NAME%%</tspan></text> <text id="text114" x="205.99434" y="491.19165" fill="#000000" font-family="Arial" font-size="14.026px" font-weight="bold" letter-spacing="0px" stroke-width="1.1689" text-align="center" text-anchor="middle" word-spacing="0px" style="font-feature-settings:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal;line-height:1.25" xml:space="preserve"><tspan id="tspan112" x="205.99434" y="491.19165" font-family="Arial" font-size="14.026px" font-weight="bold" stroke-width="1.1689" text-align="center" text-anchor="middle" style="font-feature-settings:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal">%BARCODE_SEC_1_NUMBERS%</tspan></text> <text id="text136" x="207.86935" y="558.71216" fill="#000000" font-family="Arial" font-size="14.026px" font-weight="bold" letter-spacing="0px" stroke-width="1.1689" text-align="center" text-anchor="middle" word-spacing="0px" style="font-feature-settings:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal;line-height:1.25" xml:space="preserve"><tspan id="tspan134" x="207.86935" y="558.71216" font-family="Arial" font-size="14.026px" font-weight="bold" stroke-width="1.1689" text-align="center" text-anchor="middle" style="font-feature-settings:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal">%BARCODE_SEC_2_NUMBERS%</tspan></text> <text id="text140" x="142.45319" y="142.38881" fill="#000000" font-family="Arial" font-size="31.17px" letter-spacing="0px" stroke-width="1.1689" text-align="center" text-anchor="middle" word-spacing="0px" style="font-feature-settings:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal;line-height:1.25" xml:space="preserve"><tspan id="tspan138" x="142.45319" y="142.38881" font-family="Arial" font-size="12.468px" stroke-width="1.1689" text-align="center" text-anchor="middle" style="font-feature-settings:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal">%ACCEPTANCE_BARCODE_NUMBERS%</tspan></text> <text id="text144" x="275.82956" y="124.89323" fill="#000000" font-family="Arial" font-size="9.1534px" letter-spacing="0px" stroke-width="1.3731" word-spacing="0px" style="font-feature-settings:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal;line-height:1.25" xml:space="preserve"><tspan id="tspan142" x="275.82956" y="124.89323" font-family="Arial" font-size="9.1534px" stroke-width="1.3731" style="font-feature-settings:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal">進店:</tspan></text> <text id="text148" x="275.82956" y="140.67513" fill="#000000" font-family="Arial" font-size="9.1534px" letter-spacing="0px" stroke-width="1.3731" word-spacing="0px" style="font-feature-settings:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal;line-height:1.25" xml:space="preserve"><tspan id="tspan146" x="275.82956" y="140.67513" font-family="Arial" font-size="9.1534px" stroke-width="1.3731" style="font-feature-settings:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal">退貨:</tspan></text> <text id="text152" x="301.93042" y="124.89323" fill="#000000" font-family="Arial" font-size="9.1534px" letter-spacing="0px" stroke-width="1.3731" word-spacing="0px" style="font-feature-settings:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal;line-height:1.25" xml:space="preserve"><tspan id="tspan150" x="301.93042" y="124.89323" font-family="Arial" font-size="9.1534px" stroke-width="1.3731" style="font-feature-settings:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal">%IN_DATE%</tspan></text> <text id="text156" x="301.93042" y="140.67513" fill="#000000" font-family="Arial" font-size="9.1534px" letter-spacing="0px" stroke-width="1.3731" word-spacing="0px" style="font-feature-settings:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal;line-height:1.25" xml:space="preserve"><tspan id="tspan154" x="301.93042" y="140.67513" font-family="Arial" font-size="9.1534px" stroke-width="1.3731" style="font-feature-settings:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal">%RETURN_DATE%</tspan></text> <text id="text160" x="335.27927" y="34.264648" fill="#000000" font-family="Arial" font-size="31.17px" letter-spacing="0px" stroke-width="1.1689" text-align="center" text-anchor="middle" word-spacing="0px" style="font-feature-settings:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal;line-height:1.25" xml:space="preserve"><tspan id="tspan158" x="335.27927" y="34.264648" font-family="Arial" font-size="12.468px" stroke-width="1.1689" text-align="center" text-anchor="middle" style="font-feature-settings:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal">店配</tspan></text> <text id="text164" x="16.190416" y="30.905792" fill="#000000" font-family="Arial" font-size="14.026px" letter-spacing="0px" stroke-width="1.1689" word-spacing="0px" style="font-feature-settings:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal;line-height:1.25" xml:space="preserve"><tspan id="tspan162" x="16.190416" y="30.905792" font-family="Arial" font-size="14.026px" stroke-width="1.1689" style="font-feature-settings:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal">客戶代碼:</tspan></text> <text id="text168" x="86.984222" y="30.905792" fill="#000000" font-family="Arial" font-size="14.026px" letter-spacing="0px" stroke-width="1.1689" word-spacing="0px" style="font-feature-settings:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal;line-height:1.25" xml:space="preserve"><tspan id="tspan166" x="86.984222" y="30.905792" font-family="Arial" font-size="14.026px" stroke-width="1.1689" style="font-feature-settings:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal">%ACCOUNT_CODE%</tspan></text> <text id="text172" x="142.45441" y="87.159737" fill="#000000" font-family="Arial" font-size="10.909px" letter-spacing="0px" stroke-width="1.1689" text-align="center" text-anchor="middle" word-spacing="0px" style="font-feature-settings:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal;line-height:1.25" xml:space="preserve"><tspan id="tspan170" x="142.45441" y="87.159737" font-family="Arial" font-size="10.909px" stroke-width="1.1689" text-align="center" text-anchor="middle" style="font-feature-settings:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal">%TRACKING_NUMBER_OF_PELICAN_NUMBERS%</tspan></text> <text id="text176" x="313.05444" y="66.269211" fill="#000000" font-family="Arial" font-size="23.377px" letter-spacing="0px" stroke-width="1.1689" text-align="center" text-anchor="middle" word-spacing="0px" style="font-feature-settings:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal;line-height:1.25" xml:space="preserve"><tspan id="tspan174" x="313.05444" y="66.269211" font-family="Arial" font-size="23.377px" stroke-width="1.1689" text-align="center" text-anchor="middle" style="font-feature-settings:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal">297A</tspan></text> <text id="text180" x="286.38077" y="185.84865" fill="#000000" font-family="Arial" font-size="31.17px" font-weight="bold" letter-spacing="0px" stroke-width="1.1689" text-align="center" text-anchor="middle" word-spacing="0px" style="font-feature-settings:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal;line-height:1.25" xml:space="preserve"><tspan id="tspan178" x="286.38077" y="185.84865" font-family="Arial" font-size="31.17px" font-weight="bold" stroke-width="1.1689" text-align="center" text-anchor="middle" style="font-feature-settings:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal">%SHORT_NAME_OF_CHANNEL%</tspan></text> <rect id="ACCEPTANCE_BARCODE" x="15.706" y="96.86" width="253.29" height="31.779" fill="none" stroke="#000" stroke-width=".86133" barcodeType="CODE_128" rotateX="0" rotateY="0" scaleX="7.7318348" scaleY="2.1185725" textPosition="NONE" translateX="-0.53075848" translateY="96.859978"/> <rect id="CHANNEL_CODE_AND_ROUTING_STEP_CODE" x="243.92" y="200.33" width="103.37" height="55.561" fill="none" stroke="#000" stroke-width=".72756" barcodeType="CODE_128" rotateX="0" rotateY="0" scaleX="5.423546" scaleY="3.6753606" textPosition="NONE" translateX="229.26353" translateY="201.20941"/> <image id="qrImage" x="28.422" y="186.74" width="95" height="95" image-rendering="optimizeSpeed" preserveAspectRatio="none" xlink:href="data:image/png;base64,%QR_CODE%"/> <rect id="TRACKING_NUMBER_OF_PELICAN" x="14.967" y="40.445" width="253.29" height="31.779" fill="none" stroke="#000" stroke-width=".86133" barcodeType="CODE_128" rotateX="0" rotateY="0" scaleX="9.8062289" scaleY="2.118572" textPosition="NONE" translateX="-5.6263182" translateY="40.444595"/> <rect id="BARCODE_SEC_1" x="133.04" y="436.19" width="143.23" height="37.133" fill="none" stroke="#000" stroke-width=".70015" barcodeType="CODE_128" rotateX="0" rotateY="0" scaleX="6.7531493" scaleY="2.4755127" textPosition="NONE" translateX="118.85838" translateY="436.18967"/> <rect id="BARCODE_SEC_2" x="86.129" y="507.02" width="243.82" height="37.133" fill="none" stroke="#000" stroke-width=".8385" barcodeType="CODE_128" rotateX="0" rotateY="0" scaleX="9.4393228" scaleY="2.4755151" textPosition="NONE" translateX="66.306246" translateY="507.02151"/> </g> </svg> `; const subst = `$1<![CDATA[$2]]>$3`; // The substituted value will be contained in the result variable const result = str.replace(regex, subst); console.log('Substitution result: ', result);

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 JavaScript, please visit: https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions