Save & Share

Flavor

  • PCRE2 (PHP)
  • ECMAScript (JavaScript)
  • Python
  • Golang
  • Java
  • .NET 7.0 (C#)
  • Rust
  • PCRE (Legacy)
  • Regex Flavor Guide

Function

  • Match
  • Substitution
  • List
  • Unit Tests
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
Processing...

Test String

Substitution
Processing...

Code Generator

Generated Code

package main import ( "regexp" "fmt" ) func main() { var re = regexp.MustCompile(`(?mi)^(.*?)(,)([^,]+)(,)([^,]+)(,)([^,]+)(,)([^,]+)(,)([^,]+)(,)([^,]+)(,)([^,]+)(,)([^,]+)(,)([^,]+)(,)([^,]+)(,)([^,]+)(,)([^,]+)$`) var str = []byte(`Statements in Highest 5 Percent by Runtime SELECT \`mid\` . \`f1\` AS \`Policy_or_Vehicle\` , \`mid\` . \`f2\` AS STATUS , \`STR_TO_DATE\` ( \`mid\` . \`datemidfile\` , ? ) AS \`Added_to_MID\` , \`STR_TO_DATE\` ( \`mid\` . \`f4\` , ? ) AS \`Off_Date\` , \`mid\` . \`f5\` AS \`Policy_Number\` , \`mid\` . \`f7\` AS \`Client_or_VRM\` , \`ins\` . \`insurerliststr\` AS \`Insurer\` FROM \`www\` . \`midfile\` \`mid\` JOIN \`insurerlist\` \`ins\` ON \`mid\` . \`insurerid\` = \`ins\` . \`insurerlistuniqid\` WHERE \`mid\` . \`datemidfile\` BETWEEN DATE_SUB ( CURDATE ( ) , INTERVAL ? YEAR ) AND DATE_SUB ( CURDATE ( ) , INTERVAL ? SQL_TSI_DAY ) AND \`mid\` . \`insurerid\` IN (...) ORDER BY \`mid\` . \`datemidfile\` , \`mid\` . \`f4\` , \`mid\` . \`f5\` , *, 1, 1, 0, 60600289.86, 60600289.86, 60600289.86, 9573, 9573.0, 171130, 171130.0, 6d4644bd20c6269cf82c47990e5a70d1 Query, Full Table Scan, Executed (#), Errors (#), Warnings (#), Total Time, Maximum Time, Avg Time, Rows Sent (#), Avg. Rows Sent (#), Rows Scanned (#), Avg. Rows Scanned (#), Digest SELECT \`mid\` . \`f1\` AS \`Policy_or_Vehicle\` , \`mid\` . \`f2\` AS STATUS , \`STR_TO_DATE\` ( \`mid\` . \`datemidfile\` , ? ) AS \`Added_to_MID\` , \`STR_TO_DATE\` ( \`mid\` . \`f4\` , ? ) AS \`Off_Date\` , \`mid\` . \`f5\` AS \`Policy_Number\` , \`mid\` . \`f7\` AS \`Client_or_VRM\` , \`ins\` . \`insurerliststr\` AS \`Insurer\` FROM \`www\` . \`midfile\` \`mid\` JOIN \`insurerlist\` \`ins\` ON \`mid\` . \`insurerid\` = \`ins\` . \`insurerlistuniqid\` WHERE \`mid\` . \`datemidfile\` BETWEEN DATE_SUB ( CURDATE ( ) , INTERVAL ? YEAR ) AND DATE_SUB ( CURDATE ( ) , INTERVAL ? SQL_TSI_DAY ) AND \`mid\` . \`insurerid\` IN (...) ORDER BY \`mid\` . \`datemidfile\` , \`mid\` . \`f4\` , \`mid\` . \`f5\` , *, 1, 1, 0, 60600289.86, 60600289.86, 60600289.86, 9573, 9573.0, 171130, 171130.0, 6d4644bd20c6269cf82c47990e5a70d1 SELECT \`mid\` . \`f1\` AS \`Policy_or_Vehicle\` , \`mid\` . \`f2\` AS STATUS , \`STR_TO_DATE\` ( \`mid\` . \`datemidfile\` , ? ) AS \`Added_to_MID\` , \`STR_TO_DATE\` ( \`mid\` . \`f4\` , ? ) AS \`Off_Date\` , \`mid\` . \`f5\` AS \`Policy_Number\` , \`mid\` . \`f7\` AS \`Client_or_VRM\` , \`ins\` . \`insurerliststr\` AS \`Insurer\` FROM \`www\` . \`midfile\` \`mid\` JOIN \`insurerlist\` \`ins\` ON \`mid\` . \`insurerid\` = \`ins\` . \`insurerlistuniqid\` WHERE \`STR_TO_DATE\` ( \`mid\` . \`datemidfile\` , ? ) BETWEEN DATE_SUB ( CURDATE ( ) , INTERVAL ? YEAR ) AND DATE_SUB ( CURDATE ( ) , INTERVAL ? SQL_TSI_DAY ) AND \`mid\` . \`insurerid\` IN (...) ORDER BY \`STR_TO_DATE\` ( \`mid\` . \`datemidfile\` , ? ) , \`STR_TO_DATE\` ( \`mid\` . \`f4\` , ? ) , \`mid\` . \`f5\` , *, 2, 2, 0, 121169467.61, 60699529.99, 60584733.81, 18477, 9239.0, 340902, 170451.0, 429fa2d77b34b01ec2a01d75cb59d0d6 SELECT SQL_NO_CACHE * FROM \`emaillogs\` , *, 2, 1, 0, 48753509.34, 33565241.24, 24376754.67, 1090956, 545478.0, 1090956, 545478.0, a6b13eb5a63a88b3a941da64fe29ee87 SELECT SQL_NO_CACHE * FROM \`claim_payments_history\` , *, 2, 0, 0, 41465341.13, 24333684.60, 20732670.56, 9408025, 4704013.0, 9408025, 4704013.0, c63a71ee443d1d2b517f1cec39824dd1 SELECT `) var substitution = []byte(""\1;"\t\3\t\5\t\7\t\9\t\11\t\13\t\15\t\17\t\19\t\21\t\23\t\25") var count = 1 // negative counter is equivalent to global case (replace all) str = re.ReplaceAllStringFunc(str, func(s string) string { if count == 0 { return s } count -= 1 return re.ReplaceAllString(s, substitution) }) fmt.Println(string(str)) }

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 Golang, please visit: https://golang.org/pkg/regexp/