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

@"
"
g

Test String

Substitution

Processing...

Code Generator

Generated Code

import java.util.regex.Matcher; import java.util.regex.Pattern; public class Example { public static void main(String[] args) { final String regex = "(?sm)^-(?:(?!^-\\r?$).)*?^:86:(?!/..../)(?:(?!^-\\r?$).)*"; final String string = "-\n" + ":20:296535/00000010\n" + ":21:ABNADK2AXXX\n" + ":25:ABNADK2AXXX/DK88ABNA0496434500\n" + ":28C:42/00002\n" + ":60M:C230228EUR124792,65\n" + ":61:2302280228C1750,88NTRFC1165-23-00120//656\n" + ":86:/TRTP/SEPA OVERBOEKING/IBAN/DK47ABNA0243508514/BIC/ABNADK2A/NAME/\n" + "LOOP BV/REMI/AV-RUN 24022023/202301918/EREF/C1165-23-00120\n" + ":61:2302280228C4695,98NTRF6381310605374038//656\n" + ":86:/TRTP/SEPA OVERBOEKING/IBAN/DK14ABNA0456766324/BIC/ABNADK2A/NAME/\n" + "DEV BV/REMI/ID16145 DEB. 1657139 FACT. 202303668 20\n" + "2303685 202303689/EREF/638131060537403857-311-2\n" + ":61:2302280228C1349,25NTRFNOTPROVIDED//658\n" + ":86:/TRTP/SEPA OVERBOEKING/IBAN/DK46ABNA0513892443/BIC/ABNADK2A/NAME/\n" + "EXAMPLE COM/REMI/202303656/EREF/NOTPROVIDED\n" + ":61:2302280228C55845,96NTRFNOTPROVIDED//658\n" + ":86:/TRTP/SEPA OVERBOEKING/IBAN/DK35ABNA0442867689/BIC/ABNADK2A/NAME/\n" + "BATH COMPANY DK/REMI/INV. 202228255-8426, OUR REF 2022611\n" + "73-79/EREF/NOTPROVIDED\n" + ":61:2302280228D105000,NTRFNOTPROVIDED//658\n" + ":86:/TRTP/SEPA OVERBOEKING/IBAN/DK98INGB0657624985/BIC/INGBDK2A/NAME/\n" + "TEST/REMI/OVERBOEKING/EREF/NOTPROVIDED\n" + ":62F:C230228EUR83434,72\n" + ":64:C230228EUR83434,72\n" + ":86:/ACSI/ABNADK2AXXX\n" + "-\n" + ":20:STARTUMS TA FW\n" + ":25:28020050/0521322890\n" + ":28C:017/01\n" + ":60F:C230228GBP1473111,27\n" + ":61:2302280228D1919,29N020NONREF\n" + ":86:206?00AUSL-ZAHLUNG?100004649?20COMPANY?21S LT\n" + "D?22TRN AZV2023022800746?23URSP.-BETR.1.900,00 GBP?24KURS 0,87716\n" + "0 EUR ZU GBP?25GEGENWERT 2.00,08 EUR?26PROVISION FIX 7\n" + ",50 EUR?27SWIFT-/TELE-SPESEN 2,00 EUR?28FREMDE GEB. 12,50 E\n" + "UR?2917.02 413337?3028020050?310537246190?32HOMETESTEXAMPLE?33S \n" + "LTD?34003\n" + ":61:2302280228D16988,81N020NONREF\n" + ":86:206?00AUSL-ZAHLUNG?100004649?20BODO GU COM?21NOT A TEST?22TRN\n" + "AZV2023022800749?23URSP.-BETR.16.980,48 GBP?24\n" + "KURS 0,877160 EUR ZU GBP?25GEGENWERT 19.358,48 EUR?26PROVISIO\n" + "N FIX 7,50 EUR?27SWIFT-/TELE-SPESEN 2,00 EUR?2830.01 INV-278\n" + "0?29*LOREM*?3028020050?310537246190?32GOLL\n" + "?33GOL COM?34003?60INFO 0800-1234\n" + "*GEB-FREI*\n" + ":61:2302280228D867,06N020NONREF\n" + ":86:206?00AUSL-ZAHLUNG?100004649?20NOTACOMPANY?21LTD?2\n" + "2TRN AZV2023022800752?23URSP.-BETR.858,73 GBP?24KURS 0,877160 EUR\n" + " ZU GBP?25GEGENWERT 978,99 EUR?26PROVISION FIX 7,50 E\n" + "UR?27SWIFT-/TELE-SPESEN 2,00 EUR?2828.01 A221322?3028020050?31053\n" + "7246190?32KOLL?33LTD?34003\n" + ":62F:C230228GBP1453336,11\n" + "-"; final String subst = ""; final Pattern pattern = Pattern.compile(regex); final Matcher matcher = pattern.matcher(string); // The substituted value will be contained in the result variable final String result = matcher.replaceAll(subst); System.out.println("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 Java, please visit: https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html