Regular Expressions 101

Save & Share

  • Regex Version: ver. 3
  • 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

/
/
g

Test String

Code Generator

Generated Code

$re = '/(?<=DIA\s).*?(?=\s)/'; $str = 'Showing first 10 out of 413 items. Use the filters below to find additional items.Search:StateCountryAllAfghanistanAland IslandsAlbaniaAlgeriaAmerican SamoaAndorraAngolaAnguillaAntarcticaAntigua and BarbudaArgentinaArmeniaArubaAustraliaAustriaAzerbaijanBahamasBahrainBangladeshBarbadosBelarusBelgiumBelizeBeninBermudaBhutanPlurinational State of BoliviaBonaire, Sint Eustatius and SabaBosnia and HerzegovinaBotswanaBouvet IslandBrazilBritish Indian Ocean TerritoryBrunei DarussalamBulgariaBurkina FasoBurundiCambodiaCameroonCape VerdeCayman IslandsCentral African RepublicChadChileChinaChristmas IslandCocos (Keeling) IslandsColombiaComorosCongoThe Democratic Republic of the CongoCook IslandsCosta RicaCote d\'IvoireCroatiaCubaCuracaoCyprusCzech RepublicDenmarkDjiboutiDominicaDominican RepublicEcuadorEgyptEl SalvadorEquatorial GuineaEritreaEstoniaEthiopiaFalkland Islands (Malvinas)Faroe IslandsFijiFinlandFranceFrench GuianaFrench PolynesiaFrench Southern TerritoriesGabonGambiaGeorgiaGermanyGhanaGibraltarGreeceGreenlandGrenadaGuadeloupeGuamGuatemalaGuernseyGuineaGuinea-BissauGuyanaHaitiHeard Island and McDonald IslandsHoly See (Vatican City State)HondurasHong KongHungaryIcelandIndiaIndonesiaIslamic Republic of IranIraqIrelandIsle of ManIsraelItalyJamaicaJapanJerseyJordanKazakhstanKenyaKiribatiDemocratic People\'s Republic of KoreaRepublic of KoreaKuwaitKyrgyzstanLao People\'s Democratic RepublicLatviaLebanonLesothoLiberiaLibyan Arab JamahiriyaLiechtensteinLithuaniaLuxembourgMacaoThe Former Yugoslav Republic of MacedoniaMadagascarMalawiMalaysiaMaldivesMaliMaltaMarshall IslandsMartiniqueMauritaniaMauritiusMayotteMexicoFederated States of MicronesiaRepublic of MoldovaMonacoMongoliaMontenegroMontserratMoroccoMozambiqueMyanmarNamibiaNauruNepalNetherlandsNew CaledoniaNew ZealandNicaraguaNigerNigeriaNiueNorfolk IslandNorthern Mariana IslandsNorwayOccupied Palestinian TerritoryOmanPakistanPalauPanamaPapua New GuineaParaguayPeruPhilippinesPitcairnPolandPortugalPuerto RicoQatarReunionRomaniaRussian FederationRwandaSaint BarthelemySaint Helena, Ascension and Tristan da CunhaSaint Kitts and NevisSaint LuciaSaint Martin (French part)Saint Pierre and MiquelonSaint Vincent and The GrenadinesSamoaSan MarinoSao Tome and PrincipeSaudi ArabiaSenegalSerbiaSeychellesSierra LeoneSingaporeSint Maarten (Dutch part)SlovakiaSloveniaSolomon IslandsSomaliaSouth AfricaSouth Georgia and the South Sandwich IslandsSouth SudanSpainSri LankaSudanSurinameSvalbard and Jan MayenSwazilandSwedenSwitzerlandSyrian Arab RepublicTaiwan, Province of ChinaTajikistanThailandTimor-LesteTogoTokelauTongaTrinidad and TobagoTunisiaTurkeyTurkmenistanTurks and Caicos IslandsTuvaluUgandaUkraineUnited Arab EmiratesUnited KingdomUnited Republic of TanzaniaUnited States/United States Territories/CanadaUruguayUzbekistanVanuatuBolivarian Republic of VenezuelaViet NamBritish Virgin IslandsWallis and FutunaWestern SaharaYemenZambiaZimbabweSorted by Product/Service IDSorted by Service TypeSorted by Service NameSorted by Service AddressSorted by CitySorted by StateSorted by Circuit ID Show10 25 100 250 413 1 - 10 of 413 Service Type Product/Service ID Service Name Service Address City State Circuit ID DIA 8778680044 SVU-RMW ANNISTON SERF1450 COMMERCE BLVD ANNISTONALDIA DS1IT-15600804-123 SVU-RMW ANNISTON2130 ROBERTS DR ANNISTONALDIA DS1IT15598059 SVU-RNO BILLINGS1629 W KING AVE W BILLINGSMTDIA DS1IT-1483-5539-ABC SVU-ACI BELTSVILLE MD 212050 BALTIMORE AVE BELTSVILLEMDDIA DS1IT-1426-8602 SVU-JEWL/OSCO #48500 T1 LAB150 E PIERCE RD FLR 1 RM TELCO ITASCAILDIA SVUSOCAL6767IA SVU-EP INTERNET PAYMNT CIRCUIT11840 VALLEY VIEW RD BLDG MAIN FLR 1 RM TELCO EDEN PRAIRIEMNDIA ITORN07-12921789.03 SVU-MICROTRAX TUSTIN CA14452 FRANKLIN AVE FLR 1 TUSTINCADIA 69/KXFS/000703//ACSO SVU-SNR-BLAKE ROAD COLD STORAGE325 BLAKE RD N BLDG MAIN FLR 1 RM TELCO HOPKINSMNDIA 0318SUPV6522PI01243 SVU-ANR-BIG SKY OFFICE MT1414 3RD ST NW GREAT FALLSMTDIA DS1IT-13319768 ALBERTSONS250 E PARKCENTER BLVD BOISEID 1 - 10 of 413'; preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0); // Print the entire match result var_dump($matches);

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 PHP, please visit: http://php.net/manual/en/ref.pcre.php