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

/
/
gm

Test String

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 = "(?i)^(.+\\.)?(myiqos|iqos)\\.com$|^(www\\.)?iqos\\.([\\\\w]{1,3})(\\.([\\\\w]{1,2}))?$"; final String string = " am.iqos.com\n" + " Exclusive sales - iqos.cz\n" + " testdriveiqos.ru\n" + "ae.iqos.com\n" + "al.iqos.com\n" + "am.iqos.com\n" + "at.iqos.com\n" + "ba.iqos.com\n" + "bezdymu.pl\n" + "bg.iqos.com\n" + "boiler iqos.com\n" + "ca.iqos.com\n" + "calculate.iqosclub.co.uk\n" + "campanie-iqos.ro\n" + "ch.iqos.com\n" + "club.iqos.ro\n" + "club.it.iqos.com\n" + "co.iqos.com\n" + "companion.iqos.co.uk\n" + "comparteelcambio.com\n" + "conoce-iqos.com\n" + "conoceiqos.com\n" + "cr.iqosclub.com\n" + "cvspickup.com\n" + "cy.iqos.com\n" + "cz.club.iqos.com\n" + "cz.iqos.com\n" + "darwin.md\n" + "DCE 2.\n" + "DCE2 - iqos.com\n" + "DCE2 - veev-vape.com\n" + "de.iqos.com\n" + "discover.iqos.gr\n" + "discoveriqos.com\n" + "dk.iqos.com\n" + "do.iqos.com\n" + "ec.myiqos.com\n" + "ee.iqos.com\n" + "enqueteiqos.com\n" + "es.iqos.com\n" + "essayeriqos.com\n" + "facturi.iqos.ro\n" + "Faramentol.ro\n" + "fastdelivery.sto\n" + "foodhouse.md\n" + "futurosinhumo.com\n" + "ganaconpmi.com\n" + "ge.iqos.com\n" + "getinfo.kr\n" + "gr.iqos.com\n" + "gt.iqos.com\n" + "heatnotburn.ro\n" + "heatnotburn.se\n" + "helloiqos.ro\n" + "hk.iqos.com\n" + "hr.iqos.com\n" + "hu.iqos.com\n" + "ic.pmiopen.com\n" + "il.iqos.com\n" + "intelege.iqos.ro\n" + "iqommunity.ro\n" + "iqos-care.nl\n" + "iqos-coach.com\n" + "iqos-on.ro\n" + "iqos-partner.ch\n" + "iqos.by\n" + "iqos.com\n" + "iqos.com (raw excl.\n" + "iqos.com.ar\n" + "iqos.com.co\n" + "iqos.com.cw\n" + "iqos.com.ua\n" + "iqos.id\n" + "iqos.lv\n" + "iqos.ro\n" + "iqos.ro v1.\n" + "iqos.ru\n" + "iqos.ru and shop.iqos.ru (Production) - Consolidated - Deprecated after 2018.11.\n" + "iqos1year.com\n" + "iqos3.es\n" + "iqos3duo.es\n" + "iqosandco.es\n" + "iqosasia.com\n" + "iqosclub.cz\n" + "iqosclub.sk\n" + "iqosclubcanarias.com\n" + "iqoscr.com\n" + "iqosempfehlen.at\n" + "iqosexpert.ch\n" + "iqosinfo.at\n" + "iqositalia.it\n" + "iqosjetzt.com\n" + "iqosnc.com\n" + "iqosphere.jp\n" + "iqosplus.de\n" + "iqospointdevente.com\n" + "iqosprobieren.at\n" + "iqosregistrieren.at\n" + "iqosrent.nl\n" + "iqossvc.kr\n" + "iqostestdrive.ru\n" + "iqostesten.at\n" + "iqosveda.cz\n" + "iqosveda.sk\n" + "iqoswechseln.at\n" + "irefer.co.iqos.com\n" + "irefer.gt.iqos.com\n" + "irefer.my.iqos.com\n" + "it.iqos-boutique.com\n" + "it.iqos.com\n" + "it.veev-vape.com\n" + "jo.iqos.com\n" + "jp.iqos.com\n" + "kontaktai.iqos.lt\n" + "kr.iqos.com\n" + "kw.iqos.com\n" + "kz.iqos.com\n" + "lb.iqos.com\n" + "lil.iqos.ru\n" + "line.iqosphere.jp\n" + "lt.iqos.com\n" + "malaysia.iqos.com\n" + "mc.myiqos.com\n" + "md.iqos.com\n" + "me.iqos.com\n" + "menthol-ban-retail.co.uk\n" + "miasesoriqos.com\n" + "mk.iqos.com\n" + "mx.iqos.com\n" + "my.iqos.com\n" + "nazareth.iqos.co.il\n" + "newcreations.kr\n" + "nl.iqos.com\n" + "nokemuhara.jp\n" + "nuevoiqos3.es\n" + "nz.iqos.com\n" + "ocsg.chat.iqos.jp\n" + "offer.jp.iqos.com\n" + "openinsieme.com\n" + "pe.myiqos.com\n" + "pl.iqos.com\n" + "pmi.23video.com\n" + "probar-iqos.com\n" + "prohibicionmentolado2020.es\n" + "proibicao-mentol2020.pt\n" + "promisiunea.iqos.ro\n" + "provaiqos.it\n" + "pruebaiqos.es\n" + "ps.iqos.com\n" + "pt.iqos.com\n" + "qreator.ro\n" + "quiz.sogo-wp.com\n" + "re.iqos.com\n" + "referidos.iqos.com.co\n" + "referiqos.com\n" + "referiqosmy.com\n" + "register.iqos.id\n" + "rs.club.iqos.com\n" + "rs.iqos.com\n" + "sa.iqos.com\n" + "sahmatlafumat.iqos.ro\n" + "se.iqos.com\n" + "sg.myiqos.com\n" + "shareiqos.ch\n" + "shop.iqos.ru (Production) - Deprecated after 2018.11.\n" + "shop.iqos.ru (raw) - Deprecated after 2018.11.\n" + "si.iqos.com\n" + "sk.club.iqos.com\n" + "sk.iqos.com\n" + "smokefreeupdates.co.il\n" + "sms.sogo-wp.com\n" + "sogo-wp.com\n" + "stores.heattobacco.de\n" + "systemiqos.pl\n" + "teigaku.jp.iqos.com\n" + "testeiqos.at\n" + "testiqos.ch\n" + "testirajiqos.rs\n" + "timeforchanges.ch\n" + "tobacco-roll.co.il\n" + "tr.myiqos.com\n" + "trans.sogo-wp.com\n" + "tryiqos.ch\n" + "tryiqos.kr\n" + "tryiqos.ru\n" + "uk.iqos.com\n" + "uk.veev-vape.com\n" + "unsmoke.de\n" + "vn.iqos.com\n" + "www.iqos.com\n" + "www.iqosclub.ch\n" + "www.mystartapp.org\n" + "www.ordenar-unidades.com\n" + "Yext - de.iqos.com\n" + "yourdecision.ro\n" + "za.iqos.com"; final Pattern pattern = Pattern.compile(regex, Pattern.MULTILINE); final Matcher matcher = pattern.matcher(string); while (matcher.find()) { System.out.println("Full match: " + matcher.group(0)); for (int i = 1; i <= matcher.groupCount(); i++) { System.out.println("Group " + i + ": " + matcher.group(i)); } } } }

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