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

Substitution

Processing...

Code Generator

Generated Code

# If you'd like to omit non-matching lines from the result; add ';d' to the end of the expression. sed -E 's/^var (.*?Infos) = .*?data\s*: (.*?),\r*$/var $1 = {\n data: $1_data,/gms;t' <<< " var activeThreadsOverTimeInfos = { data: [\"some\", \"activeThreadsOverTimeInfos\", \"data\"], getOptions: function() { return { ... var timeVsThreadsInfos = { data: [\"some\", \"timeVsThreadsInfos\", \"data\"], getOptions: function() { return { ... var bytesThroughputOverTimeInfos = { data : {\"result\": {\"minY\": 0.0, \"minX\": 1.5931058173E12, \"maxY\": 14780.0, \"series\": [{\"data\": [[1.5931058186E12, 4010.0], [1.5931058196E12, 3990.0], [1.5931058175E12, 4120.0], [1.5931058185E12, 4090.0], [1.5931058195E12, 4120.0], [1.5931058205E12, 4340.0], [1.5931058184E12, 4230.0], [1.5931058194E12, 4350.0], [1.5931058204E12, 4010.0], [1.5931058173E12, 4010.0], [1.5931058224E12, 700.0], [1.5931058183E12, 3990.0], [1.5931058193E12, 4320.0], [1.5931058203E12, 4010.0], [1.5931058213E12, 4010.0], [1.5931058192E12, 4340.0], [1.5931058202E12, 4120.0], [1.5931058212E12, 4090.0], [1.5931058181E12, 4120.0], [1.5931058191E12, 4010.0], [1.5931058201E12, 4010.0], [1.5931058211E12, 4230.0], [1.593105818E12, 4350.0], [1.593105819E12, 4010.0], [1.59310582E12, 4010.0], [1.593105821E12, 3990.0], [1.5931058179E12, 4320.0], [1.5931058189E12, 4120.0], [1.5931058209E12, 4120.0], [1.5931058178E12, 4340.0], [1.5931058198E12, 4090.0], [1.5931058208E12, 4350.0], [1.5931058177E12, 4010.0], [1.5931058187E12, 4010.0], [1.5931058197E12, 4230.0], [1.5931058207E12, 4320.0], [1.5931058176E12, 4010.0], [1.5931058217E12, 270.0]], \"isOverall\": false, \"label\": \"Bytes received per second\", \"isController\": false}, {\"data\": [[1.5931058186E12, 9000.0], [1.5931058196E12, 14780.0], [1.5931058175E12, 8930.0], [1.5931058185E12, 9130.0], [1.5931058195E12, 9250.0], [1.5931058205E12, 9150.0], [1.5931058184E12, 9020.0], [1.5931058194E12, 9480.0], [1.5931058204E12, 9200.0], [1.5931058173E12, 5930.0], [1.5931058224E12, 0.0], [1.5931058183E12, 14780.0], [1.5931058193E12, 9430.0], [1.5931058203E12, 11110.0], [1.5931058213E12, 9000.0], [1.5931058192E12, 9150.0], [1.5931058202E12, 8930.0], [1.5931058212E12, 9130.0], [1.5931058181E12, 9250.0], [1.5931058191E12, 9200.0], [1.5931058201E12, 5930.0], [1.5931058211E12, 9020.0], [1.593105818E12, 9480.0], [1.593105819E12, 11110.0], [1.59310582E12, 9000.0], [1.593105821E12, 14780.0], [1.5931058179E12, 9430.0], [1.5931058189E12, 8930.0], [1.5931058209E12, 9250.0], [1.5931058178E12, 9150.0], [1.5931058198E12, 9130.0], [1.5931058208E12, 9480.0], [1.5931058177E12, 9200.0], [1.5931058187E12, 5930.0], [1.5931058197E12, 9020.0], [1.5931058207E12, 9430.0], [1.5931058176E12, 11110.0], [1.5931058217E12, 0.0]], \"isOverall\": false, \"label\": \"Bytes sent per second\", \"isController\": false}], \"supportsControllersDiscrimination\": false, \"granularity\": 100, \"maxX\": 1.5931058224E12, \"title\": \"Bytes Throughput Over Time\"}}, getOptions : function(){ return { series: { lines: { show: true }, points: { show: true } }, xaxis: { mode: \"time\", timeformat: getTimeFormat(this.data.result.granularity), axisLabel: getElapsedTimeLabel(this.data.result.granularity) , axisLabelUseCanvas: true, axisLabelFontSizePixels: 12, axisLabelFontFamily: 'Verdana, Arial', axisLabelPadding: 20, }, yaxis: { axisLabel: \"Bytes / sec\", axisLabelUseCanvas: true, axisLabelFontSizePixels: 12, axisLabelFontFamily: 'Verdana, Arial', axisLabelPadding: 20, }, legend: { noColumns: 2, show: true, container: '#legendBytesThroughputOverTime' }, selection: { mode: \"xy\" }, grid: { hoverable: true // IMPORTANT! this is needed for tooltip to // work }, tooltip: true, tooltipOpts: { content: \"%s at %x was %y\" } }; }, createGraph : function() { var data = this.data; var dataset = prepareData(data.result.series, $(\"#choicesBytesThroughputOverTime\")); var options = this.getOptions(); prepareOptions(options, data); $.plot($(\"#flotBytesThroughputOverTime\"), dataset, options); // setup overview $.plot($(\"#overviewBytesThroughputOverTime\"), dataset, prepareOverviewOptions(options)); } }; // Bytes throughput Over Time function refreshBytesThroughputOverTime(fixTimestamps) { var infos = bytesThroughputOverTimeInfos; prepareSeries(infos.data); if(fixTimestamps) { fixTimeStamps(infos.data.result.series, -14400000); } if(isGraph($(\"#flotBytesThroughputOverTime\"))){ infos.createGraph(); }else{ var choiceContainer = $(\"#choicesBytesThroughputOverTime\"); createLegend(choiceContainer, infos); infos.createGraph(); setGraphZoomable(\"#flotBytesThroughputOverTime\", \"#overviewBytesThroughputOverTime\"); $('#footerBytesThroughputOverTime .legendColorBox > div').each(function(i){ $(this).clone().prependTo(choiceContainer.find(\"li\").eq(i)); }); } } var responseTimesOverTimeInfos = { data: {\"result\": {\"minY\": 106.0, \"minX\": 1.5931058172E12, \"maxY\": 711.0, \"series\": [{\"data\": [[1.5931058181E12, 108.0], [1.5931058209E12, 107.0], [1.5931058195E12, 107.0]], \"isOverall\": false, \"label\": \"createOrder\", \"isController\": false}, {\"data\": [[1.5931058175E12, 107.0], [1.5931058202E12, 106.0], [1.5931058189E12, 107.0]], \"isOverall\": false, \"label\": \"T02_ Login page\", \"isController\": true}, {\"data\": [[1.5931058204E12, 220.0], [1.5931058191E12, 219.0], [1.5931058177E12, 226.0]], \"isOverall\": false, \"label\": \"T03_ Login submit\", \"isController\": true}, {\"data\": [[1.5931058186E12, 215.0], [1.5931058213E12, 213.0], [1.59310582E12, 214.0]], \"isOverall\": false, \"label\": \"T05_ SignOff\", \"isController\": true}, {\"data\": [[1.5931058201E12, 148.0], [1.5931058172E12, 320.0], [1.5931058187E12, 146.0]], \"isOverall\": false, \"label\": \"T01_ Home page\", \"isController\": true}, {\"data\": [[1.5931058196E12, 116.0], [1.5931058183E12, 135.0], [1.593105821E12, 130.0]], \"isOverall\": false, \"label\": \"placeOrder\", \"isController\": false}, {\"data\": [[1.5931058203E12, 112.0], [1.593105819E12, 112.0], [1.5931058176E12, 119.0]], \"isOverall\": false, \"label\": \"viewAccount\", \"isController\": false}, {\"data\": [[1.5931058198E12, 107.0], [1.5931058185E12, 107.0], [1.5931058212E12, 107.0]], \"isOverall\": false, \"label\": \"signOff\", \"isController\": false}, {\"data\": [[1.5931058175E12, 107.0], [1.5931058202E12, 106.0], [1.5931058189E12, 107.0]], \"isOverall\": false, \"label\": \"signonForm\", \"isController\": false}, {\"data\": [[1.5931058193E12, 107.0], [1.5931058179E12, 109.0], [1.5931058207E12, 107.0]], \"isOverall\": false, \"label\": \"viewProduct\", \"isController\": false}, {\"data\": [[1.5931058211E12, 108.0], [1.5931058197E12, 108.0], [1.5931058184E12, 107.0]], \"isOverall\": false, \"label\": \"confirmOrder\", \"isController\": false}, {\"data\": [[1.5931058224E12, 711.0]], \"isOverall\": false, \"label\": \"JDBC Request\", \"isController\": false}, {\"data\": [[1.5931058178E12, 107.0], [1.5931058205E12, 107.0], [1.5931058192E12, 108.0]], \"isOverall\": false, \"label\": \"viewCategory\", \"isController\": false}, {\"data\": [[1.5931058211E12, 666.0], [1.5931058197E12, 653.0], [1.5931058184E12, 674.0]], \"isOverall\": false, \"label\": \"T04_ Create Order\", \"isController\": true}, {\"data\": [[1.5931058204E12, 108.0], [1.5931058186E12, 108.0], [1.5931058173E12, 320.0], [1.5931058191E12, 107.0], [1.5931058201E12, 148.0], [1.5931058213E12, 106.0], [1.5931058177E12, 107.0], [1.59310582E12, 107.0], [1.5931058187E12, 146.0]], \"isOverall\": false, \"label\": \"viewCatalog\", \"isController\": false}, {\"data\": [[1.593105818E12, 108.0], [1.5931058208E12, 107.0], [1.5931058194E12, 107.0]], \"isOverall\": false, \"label\": \"viewCart\", \"isController\": false}, {\"data\": [[1.5931058217E12, 358.0]], \"isOverall\": false, \"label\": \"OS Process Sampler\", \"isController\": false}], \"supportsControllersDiscrimination\": true, \"granularity\": 100, \"maxX\": 1.5931058224E12, \"title\": \"Response Time Over Time\"}}, getOptions: function(){ return { series: { lines: { show: true }, points: { show: true } }, xaxis: { mode: \"time\", timeformat: getTimeFormat(this.data.result.granularity), axisLabel: getElapsedTimeLabel(this.data.result.granularity), axisLabelUseCanvas: true, axisLabelFontSizePixels: 12, axisLabelFontFamily: 'Verdana, Arial', axisLabelPadding: 20, }, yaxis: { axisLabel: \"Average response time in ms\", axisLabelUseCanvas: true, axisLabelFontSizePixels: 12, axisLabelFontFamily: 'Verdana, Arial', axisLabelPadding: 20, }, legend: { noColumns: 2, show: true, container: '#legendResponseTimesOverTime' }, selection: { mode: 'xy' }, grid: { hoverable: true // IMPORTANT! this is needed for tooltip to // work }, tooltip: true, tooltipOpts: { content: \"%s : at %x Average response time was %y ms\" } }; }, createGraph: function() { var data = this.data; var dataset = prepareData(data.result.series, $(\"#choicesResponseTimesOverTime\")); var options = this.getOptions(); prepareOptions(options, data); $.plot($(\"#flotResponseTimesOverTime\"), dataset, options); // setup overview $.plot($(\"#overviewResponseTimesOverTime\"), dataset, prepareOverviewOptions(options)); } }; // Response Times Over Time function refreshResponseTimeOverTime(fixTimestamps) { var infos = responseTimesOverTimeInfos; prepareSeries(infos.data); if(infos.data.result.series.length == 0) { setEmptyGraph(\"#bodyResponseTimeOverTime\"); return; } if(fixTimestamps) { fixTimeStamps(infos.data.result.series, -14400000); } if(isGraph($(\"#flotResponseTimesOverTime\"))){ infos.createGraph(); }else{ var choiceContainer = $(\"#choicesResponseTimesOverTime\"); createLegend(choiceContainer, infos); infos.createGraph(); setGraphZoomable(\"#flotResponseTimesOverTime\", \"#overviewResponseTimesOverTime\"); $('#footerResponseTimesOverTime .legendColorBox > div').each(function(i){ $(this).clone().prependTo(choiceContainer.find(\"li\").eq(i)); }); } }; var latenciesOverTimeInfos = { data: [\"some\", \"latenciesOverTimeInfos\", \"data\"], getOptions: function() { return { ... var connectTimeOverTimeInfos = { data: [\"some\", \"connectTimeOverTimeInfos\", \"data\"], getOptions: function() { return { ... "

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 SED, please visit: https://www.gnu.org/software/sed/manual/html_node/The-_0022s_0022-Command.html