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

/
/
smg

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 = "^(\\d+\\)\\s*\\d+\\.\\s+)(.*?) ISSN"; final String string = "6) 6. ACROSS LANGUAGES AND CULTURES Semiannual ISSN: 1585-1923\n" + "AKADEMIAI KIADO ZRT, BUDAFOKI UT 187-189-A-3, BUDAPEST, HUNGARY, H-1117\n" + "Social Sciences Citation Index\n" + "Arts & Humanities Citation Index\n" + "7) 7. ACTA ANALYTICA-INTERNATIONAL PERIODICAL FOR PHILOSOPHY IN\n" + "THE ANALYTICAL TR ADITION\n" + "Quarterly ISSN: 0353-5150\n" + "SPRINGER, 233 SPRING ST, NEW YORK, USA, NY, 10013\n" + "Arts & Humanities Citation Index\n" + "8) 8. ACTA ARCHAEOLOGICA Annual ISSN: 0065-101X\n" + "WILEY, 111 RIVER ST, HOBOKEN, USA, NJ, 07030-5774\n" + "Arts & Humanities Citation Index\n" + "9) 9. ACTA BOREALIA Semiannual ISSN: 0800-3831\n" + "ROUTLEDGE JOURNALS, TAYLOR & FRANCIS LTD, 2-4 PARK SQUARE, MILTON PARK, ABINGDON, ENGLAND, OXON, OX14 4RN\n" + "Arts & Humanities Citation Index\n" + "10) 10. ACTA CLASSICA Annual ISSN: 0065-1141\n" + "UNIV FREE STATE, DEPT ENG CLASSICAL LANG, PO BOX 339, BLOEMFONTEIN, SOUTH AFRICA, 9300\n" + "Arts & Humanities Citation Index\n" + "11) 11. ACTA HISTORICA TALLINNENSIA Annual ISSN: 1406-2925\n" + "ESTONIAN ACADEMY PUBLISHERS, 6 KOHTU, TALLINN, ESTONIA, 10130\n" + "Arts & Humanities Citation Index\n" + "12) 12. ACTA HISTRIAE Tri-annual ISSN: 1318-0185\n" + "4\n" + "تاریخ انتشار: 89/2/62 پژوهشگاه و شبکه آزمایشگاهی 98/3 :Code UNIV PRIMORSKA, SCI RES CENTRE KOPER, GARIBALDIJEVA 1,\n" + "KOPER, SLOVENIA, CAPODISTRIA, SI-6000\n" + "Social Sciences Citation Index\n" + "Arts & Humanities Citation Index\n" + "13) 13. ACTA KOREANA Semiannual ISSN: 1520-7412\n" + "ACADEMIA KOREANA KEIMYUNG UNIV, 1095 DALGUBEOLDAERO, DALSEO-GU, DAEGU, SOUTH KOREA, 704-701\n" + "Arts & Humanities Citation Index\n" + "Current Contents - Arts & Humanities\n" + "14) 14. ACTA LINGUISTICA HUNGARICA Quarterly ISSN: 1216-8076\n" + "AKADEMIAI KIADO ZRT, BUDAFOKI UT 187-189-A-3, BUDAPEST, HUNGARY, H-1117\n" + "Social Sciences Citation Index\n" + "Arts & Humanities Citation Index\n" + "15)15. ACTA LITERARIA Semiannual ISSN: 0717-6848\n" + "UNIV CONCEPCION, FAC HUMANIDADES ARTE, CASILLA 160-C, CORREO 3, CONCEPCION, CHILE, 00000\n" + "Arts & Humanities Citation Index\n" + "16) 16. ACTA MUSICOLOGICA Semiannual ISSN: 0001-6241\n" + "INT MUSICOLOGICAL SOC, BOX 561, BASEL, SWITZERLAND, CH-4001\n" + "Arts & Humanities Citation Index\n" + "Current Contents - Arts & Humanities\n" + "17) 17. ACTA ORIENTALIA ACADEMIAE SCIENTIARUM HUNGARICAE Quarterly ISSN: 1588-2667\n" + "AKADEMIAI KIADO ZRT, BUDAFOKI UT 187-189-A-3, BUDAPEST, HUNGARY, H-1117\n" + "Arts & Humanities Citation Index\n" + "5\n" + "تاریخ انتشار: 89/2/62 پژوهشگاه و شبکه آزمایشگاهی 98/3 :Code Current Contents - Arts & Humanities\n" + "18) 18. ACTA PHILOSOPHICA Semiannual ISSN: 1121-2179\n" + "FABRIZIO SERRA EDITORE, PO BOX NO,1, SUCC NO. 8, PISA, ITALY, I-56123\n" + "Arts & Humanities Citation Index\n" + "Current Contents - Arts & Humanities"; final String subst = ""; final Pattern pattern = Pattern.compile(regex, Pattern.DOTALL | Pattern.MULTILINE); 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