Regular Expressions 101

Save & Share

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

/
/
gm

Test String

Code Generator

Generated Code

use strict; my $str = '"cookieHeaders": [], "data": "[{\\"profileUrl\\":\\"https://www.linkedin.com/sales/lead/ACwAAArvMwEB2tFiclj-KT4JZcFc08OcC4xEN6Q,NAME_SEARCH,L1ef\\",\\"fullName\\":\\"Brit Nørgård\\",\\"firstName\\":\\"Brit\\",\\"lastName\\":\\"Nørgård\\",\\"companyName\\":\\"Anerkjendt \\",\\"title\\":\\"Buyer\\",\\"companyId\\":\\"\\",\\"companyUrl\\":\\"\\",\\"regularCompanyUrl\\":\\"\\",\\"industry\\":\\"\\",\\"companyLocation\\":\\"\\",\\"location\\":\\"Danemark-du-Sud, Danemark\\",\\"durationInRole\\":\\"6 years 5 months in role\\",\\"durationInCompany\\":\\"6 years 5 months in company\\",\\"pastExperienceCompanyName\\":\\"\\",\\"pastExperienceCompanyUrl\\":\\"\\",\\"pastExperienceCompanyTitle\\":\\"\\",\\"pastExperienceDate\\":\\"\\",\\"pastExperienceDuration\\":\\"\\",\\"connectionDegree\\":\\"3rd\\",\\"profileImageUrl\\":\\"\\",\\"sharedConnectionsCount\\":0,\\"name\\":\\"Brit Nørgård\\",\\"vmid\\":\\"ACwAAArvMwEB2tFiclj-KT4JZcFc08OcC4xEN6Q\\",\\"linkedInProfileUrl\\":\\"https://www.linkedin.com/in/ACwAAArvMwEB2tFiclj-KT4JZcFc08OcC4xEN6Q/\\",\\"isPremium\\":false,\\"isOpenLink\\":false,\\"query\\":\\"https://www.linkedin.com/company/anerkjendt\\",\\"timestamp\\":\\"2024-05-20T21:57:51.782Z\\",\\"defaultProfileUrl\\":\\"https://linkedin.com/in/brit-nørgård-28152a51\\"},{\\"profileUrl\\":\\"https://www.linkedin.com/sales/lead/ACwAACezOk0Bnpkx35osawsPd6xgsNUFavGZHII,NAME_SEARCH,ibLy\\",\\"fullName\\":\\"Per Johansen\\",\\"firstName\\":\\"Per\\",\\"lastName\\":\\"Johansen\\",\\"companyName\\":\\"DXNMXRK Aps \\",\\"title\\":\\"Company Owner\\",\\"companyId\\":\\"\\",\\"companyUrl\\":\\"\\",\\"regularCompanyUrl\\":\\"\\",\\"industry\\":\\"\\",\\"companyLocation\\":\\"\\",\\"location\\":\\"Danemark-du-Sud, Danemark\\",\\"durationInRole\\":\\"5 years 5 months in role\\",\\"durationInCompany\\":\\"5 years 5 months in company\\",\\"pastExperienceCompanyName\\":\\"\\",\\"pastExperienceCompanyUrl\\":\\"\\",\\"pastExperienceCompanyTitle\\":\\"\\",\\"pastExperienceDate\\":\\"\\",\\"pastExperienceDuration\\":\\"\\",\\"connectionDegree\\":\\"3rd\\",\\"profileImageUrl\\":\\"\\",\\"sharedConnectionsCount\\":0,\\"name\\":\\"Per Johansen\\",\\"vmid\\":\\"ACwAACezOk0Bnpkx35osawsPd6xgsNUFavGZHII\\",\\"linkedInProfileUrl\\":\\"https://www.linkedin.com/in/ACwAACezOk0Bnpkx35osawsPd6xgsNUFavGZHII/\\",\\"isPremium\\":false,\\"isOpenLink\\":false,\\"query\\":\\"https://www.linkedin.com/company/anerkjendt\\",\\"timestamp\\":\\"2024-05-20T21:57:51.782Z\\",\\"defaultProfileUrl\\":\\"https://linkedin.com/in/per-johansen-9a5089167\\"},{\\"profileUrl\\":\\"https://www.linkedin.com/sales/lead/ACwAAAS2KpoBgOtwMDIfEn0uD_X-CBbWtLJ15C4,NAME_SEARCH,RvmY\\",\\"fullName\\":\\"Jesper Møller Christiansen\\",\\"firstName\\":\\"Jesper Møller\\",\\"lastName\\":\\"Christiansen\\",\\"companyName\\":\\"Anerkjendt\\",\\"title\\":\\"Brand manager\\",\\"companyId\\":\\"65892395\\",\\"companyUrl\\":\\"https://www.linkedin.com/sales/company/65892395\\",\\"regularCompanyUrl\\":\\"https://www.linkedin.com/company/65892395\\",\\"summary\\":\\"Experienced Buyer with a demonstrated history of working in the apparel and fashion industry. Skilled in Trend Analysis, Retail, Sales, Textiles, and Wholesale. Strong purchasing professional graduated from Haderslev handelsskole. \\",\\"industry\\":\\"Commerce de détail d’habillement et d’accessoires de mode\\",\\"companyLocation\\":\\"Danemark\\",\\"location\\":\\"Kolding, Danemark-du-Sud, Danemark\\",\\"durationInRole\\":\\"2 years 4 months in role\\",\\"durationInCompany\\":\\"2 years 4 months in company\\",\\"pastExperienceCompanyName\\":\\"\\",\\"pastExperienceCompanyUrl\\":\\"\\",\\"pastExperienceCompanyTitle\\":\\"\\",\\"pastExperienceDate\\":\\"\\",\\"pastExperienceDuration\\":\\"\\",\\"connectionDegree\\":\\"3rd\\",\\"profileImageUrl\\":\\"https://media.licdn.com/dms/image/D4E03AQHmleTCAB-Lvg/profile-displayphoto-shrink_800_800/0/1693842198052?e=1721865600&v=beta&t=iZvu4zDKCf11yD1aVmsuIaimiQai77P52G5Yhnn3oRg\\",\\"sharedConnectionsCount\\":0,\\"name\\":\\"Jesper Møller Christiansen\\",\\"vmid\\":\\"ACwAAAS2KpoBgOtwMDIfEn0uD_X-CBbWtLJ15C4\\",\\"linkedInProfileUrl\\":\\"https://www.linkedin.com/in/ACwAAAS2KpoBgOtwMDIfEn0uD_X-CBbWtLJ15C4/\\",\\"isPremium\\":false,\\"isOpenLink\\":false,\\"query\\":\\"https://www.linkedin.com/company/anerkjendt\\",\\"timestamp\\":\\"2024-05-20T21:57:51.782Z\\",\\"defaultProfileUrl\\":\\"https://linkedin.com/in/moellerjesper\\"},{\\"profileUrl\\":\\"https://www.linkedin.com/sales/lead/ACwAAAcWeOwB8AoU81dUGkxx4nuzrOdJgItYs00,NAME_SEARCH,ADHr\\",\\"fullName\\":\\"GIORGIO \\\\\\"KRENDO\\\\\\" FLORENZANI\\",\\"firstName\\":\\"GIORGIO \\\\\\"KRENDO\\\\\\"\\",\\"lastName\\":\\"FLORENZANI\\",\\"companyName\\":\\"Anerkjendt\\",\\"title\\":\\"Responsabile vendite\\",\\"companyId\\":\\"65892395\\",\\"companyUrl\\":\\"https://www.linkedin.com/sales/company/65892395\\",\\"regularCompanyUrl\\":\\"https://www.linkedin.com/company/65892395\\",\\"summary\\":\\"SALES AGENCY, CLOTHING, SHOES ACCESSORIES\\\\nBRANDS WORLDWIDE.\\",\\"titleDescription\\":\\"Dal 2015 ad oggi\\",\\"industry\\":\\"Commerce de détail d’habillement et d’accessoires de mode\\",\\"companyLocation\\":\\"Danemark\\",\\"location\\":\\"Rome, Latium, Italie\\",\\"durationInRole\\":\\"9 years 5 months in role\\",\\"durationInCompany\\":\\"9 years 5 months in company\\",\\"pastExperienceCompanyName\\":\\"\\",\\"pastExperienceCompanyUrl\\":\\"\\",\\"pastExperienceCompanyTitle\\":\\"\\",\\"pastExperienceDate\\":\\"\\",\\"pastExperienceDuration\\":\\"\\",\\"connectionDegree\\":\\"3rd\\",\\"profileImageUrl\\":\\"https://media.licdn.com/dms/image/D4D03AQH4dEH26P8gQw/profile-displayphoto-shrink_800_800/0/1710814147191?e=1721865600&v=beta&t=Bo7ViLPkq4v7KxMEy-HPQHifs2oY_7H-6EKHCzwsV_Q\\",\\"sharedConnectionsCount\\":0,\\"name\\":\\"GIORGIO \\\\\\"KRENDO\\\\\\" FLORENZANI\\",\\"vmid\\":\\"ACwAAAcWeOwB8AoU81dUGkxx4nuzrOdJgItYs00\\",\\"linkedInProfileUrl\\":\\"https://www.linkedin.com/in/ACwAAAcWeOwB8AoU81dUGkxx4nuzrOdJgItYs00/\\",\\"isPremium\\":false,\\"isOpenLink\\":false,\\"query\\":\\"https://www.linkedin.com/company/anerkjendt\\",\\"timestamp\\":\\"2024-05-20T21:57:51.782Z\\",\\"defaultProfileUrl\\":\\"https://linkedin.com/in/giorgio-krendo-florenzani-6649a733\\"},{\\"profileUrl\\":\\"https://www.linkedin.com/sales/lead/ACwAABORO9MBOYs65eTJaJi1c1rO2dEyVUyeamU,NAME_SEARCH,BdtV\\",\\"fullName\\":\\"Nicolai Kristiansen\\",\\"firstName\\":\\"Nicolai\\",\\"lastName\\":\\"Kristiansen\\",\\"companyName\\":\\"Anerkjendt \\",\\"title\\":\\"International Sales Manager\\",\\"companyId\\":\\"\\",\\"companyUrl\\":\\"\\",\\"regularCompanyUrl\\":\\"\\",\\"industry\\":\\"\\",\\"companyLocation\\":\\"\\",\\"location\\":\\"Danemark-du-Sud, Danemark\\",\\"durationInRole\\":\\"4 years 10 months in role\\",\\"durationInCompany\\":\\"4 years 10 months in company\\",\\"pastExperienceCompanyName\\":\\"\\",\\"pastExperienceCompanyUrl\\":\\"\\",\\"pastExperienceCompanyTitle\\":\\"\\",\\"pastExperienceDate\\":\\"\\",\\"pastExperienceDuration\\":\\"\\",\\"connectionDegree\\":\\"3rd\\",\\"profileImageUrl\\":\\"https://media.licdn.com/dms/image/C4E03AQGfN0x94HRoGQ/profile-displayphoto-shrink_800_800/0/1517479161588?e=1721865600&v=beta&t=Q3Opg3Gt28v5qG7rkQsX4MKXqnQkqLzQ2z5hxawagaU\\",\\"sharedConnectionsCount\\":0,\\"name\\":\\"Nicolai Kristiansen\\",\\"vmid\\":\\"ACwAABORO9MBOYs65eTJaJi1c1rO2dEyVUyeamU\\",\\"linkedInProfileUrl\\":\\"https://www.linkedin.com/in/ACwAABORO9MBOYs65eTJaJi1c1rO2dEyVUyeamU/\\",\\"isPremium\\":false,\\"isOpenLink\\":false,\\"query\\":\\"https://www.linkedin.com/company/anerkjendt\\",\\"timestamp\\":\\"2024-05-20T21:57:51.782Z\\",\\"defaultProfileUrl\\":\\"https://linkedin.com/in/nicolai-kristiansen-9abb3791\\"},{\\"profileUrl\\":\\"https://www.linkedin.com/sales/lead/ACwAAAa2UCQBdzx9Vm5sWpwqR2JJGdSu26_49ko,NAME_SEARCH,W_8F\\",\\"fullName\\":\\"Mia Toft Rasmussen\\",\\"firstName\\":\\"Mia Toft\\",\\"lastName\\":\\"Rasmussen\\",\\"companyName\\":\\".\\",\\"title\\":\\"Designer\\",\\"companyId\\":\\"\\",\\"companyUrl\\":\\"\\",\\"regularCompanyUrl\\":\\"\\",\\"summary\\":\\"Specialties: User of:\\\\nIllustrator\\\\nInDesign\\\\nPhotoshop\\\\nNavision\\",\\"industry\\":\\"\\",\\"companyLocation\\":\\"\\",\\"location\\":\\"Jutland central, Danemark\\",\\"durationInRole\\":\\"4 years 9 months in role\\",\\"durationInCompany\\":\\"4 years 9 months in company\\",\\"pastExperienceCompanyName\\":\\"\\",\\"pastExperienceCompanyUrl\\":\\"\\",\\"pastExperienceCompanyTitle\\":\\"\\",\\"pastExperienceDate\\":\\"\\",\\"pastExperienceDuration\\":\\"\\",\\"connectionDegree\\":\\"3rd\\",\\"profileImageUrl\\":\\"https://media.licdn.com/dms/image/C5603AQFaFkHFvkcgRQ/profile-displayphoto-shrink_800_800/0/1516485146922?e=1721865600&v=beta&t=R3FviLzfNnIuZ6baRmRYey4gl4XxTQss1jyg89vP7Hw\\",\\"sharedConnectionsCount\\":0,\\"name\\":\\"Mia Toft Rasmussen\\",\\"vmid\\":\\"ACwAAAa2UCQBdzx9Vm5sWpwqR2JJGdSu26_49ko\\",\\"linkedInProfileUrl\\":\\"https://www.linkedin.com/in/ACwAAAa2UCQBdzx9Vm5sWpwqR2JJGdSu26_49ko/\\",\\"isPremium\\":false,\\"isOpenLink\\":false,\\"query\\":\\"https://www.linkedin.com/company/anerkjendt\\",\\"timestamp\\":\\"2024-05-20T21:57:51.782Z\\",\\"defaultProfileUrl\\":\\"https://linkedin.com/in/mia-toft-rasmussen-74486831\\"},{\\"profileUrl\\":\\"https://www.linkedin.com/sales/lead/ACwAAA1xH_EBaQO89bWu7VduaXSWmppt-E8R-gE,NAME_SEARCH,mWcw\\",\\"fullName\\":\\"Paolo D\'Angela Owner STUDIO3 Rappresentanze\\",\\"firstName\\":\\"Paolo D\'Angela\\",\\"lastName\\":\\"Owner STUDIO3 Rappresentanze\\",\\"companyName\\":\\"Anerkjendt\\",\\"title\\":\\"Agente di vendita\\",\\"companyId\\":\\"65892395\\",\\"companyUrl\\":\\"https://www.linkedin.com/sales/company/65892395\\",\\"regularCompanyUrl\\":\\"https://www.linkedin.com/company/65892395\\",\\"summary\\":\\"Experienced Head with a demonstrated history of working in the sports industry. Skilled in Sales Management, English, Sporting Goods, Sports Marketing, and Marketing. Strong professional graduated from Università degli Studi di Bari. \\",\\"industry\\":\\"Commerce de détail d’habillement et d’accessoires de mode\\",\\"companyLocation\\":\\"Danemark\\",\\"location\\":\\"Bari et périphérie\\",\\"durationInRole\\":\\" 6 months in role\\",\\"durationInCompany\\":\\" 6 months in company\\",\\"pastExperienceCompanyName\\":\\"\\",\\"pastExperienceCompanyUrl\\":\\"\\",\\"pastExperienceCompanyTitle\\":\\"\\",\\"pastExperienceDate\\":\\"\\",\\"pastExperienceDuration\\":\\"\\",\\"connectionDegree\\":\\"3rd\\",\\"profileImageUrl\\":\\"https://media.licdn.com/dms/image/C4D03AQHn4IopmQbYUg/profile-displayphoto-shrink_800_800/0/1658689070493?e=1721865600&v=beta&t=p4NPrwlt6tI-4gaoglFGsKsy_m1X2U10YKCpFyB02jo\\",\\"sharedConnectionsCount\\":0,\\"name\\":\\"Paolo D\'Angela Owner STUDIO3 Rappresentanze\\",\\"vmid\\":\\"ACwAAA1xH_EBaQO89bWu7VduaXSWmppt-E8R-gE\\",\\"linkedInProfileUrl\\":\\"https://www.linkedin.com/in/ACwAAA1xH_EBaQO89bWu7VduaXSWmppt-E8R-gE/\\",\\"isPremium\\":false,\\"isOpenLink\\":false,\\"query\\":\\"https://www.linkedin.com/company/anerkjendt\\",\\"timestamp\\":\\"2024-05-20T21:57:51.782Z\\",\\"defaultProfileUrl\\":\\"https://linkedin.com/in/paolo-d-angela-owner-studio3-rappresentanze-a1563763\\"}]", "fileSize": 9511, "fileName": "file.json" '; my $regex = qr/\{"profileUrl":"([^"]+)","fullName":"([^"]+)","firstName":"([^"]+)","lastName":"([^"]+)","companyName":"([^"]*)","title":"([^"]*)","companyId":"([^"]*)","companyUrl":"([^"]*)","regularCompanyUrl":"([^"]*)","summary":"([^"]*)","industry":"([^"]*)","companyLocation":"([^"]*)","location":"([^"]*)","durationInRole":"([^"]*)","durationInCompany":"([^"]*)","pastExperienceCompanyName":"([^"]*)","pastExperienceCompanyUrl":"([^"]*)","pastExperienceCompanyTitle":"([^"]*)","pastExperienceDate":"([^"]*)","pastExperienceDuration":"([^"]*)","connectionDegree":"([^"]*)","profileImageUrl":"([^"]*)","sharedConnectionsCount":(\d+),"name":"([^"]+)","vmid":"([^"]+)","linkedInProfileUrl":"([^"]+)","isPremium":(true|false),"isOpenLink":(true|false),"query":"([^"]+)","timestamp":"([^"]+)","defaultProfileUrl":"([^"]+)"\} /mp; if ( $str =~ /$regex/g ) { print "Whole match is ${^MATCH} and its start/end positions can be obtained via \$-[0] and \$+[0]\n"; # print "Capture Group 1 is $1 and its start/end positions can be obtained via \$-[1] and \$+[1]\n"; # print "Capture Group 2 is $2 ... and so on\n"; } # ${^POSTMATCH} and ${^PREMATCH} are also available with the use of '/p' # Named capture groups can be called via $+{name}

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 Perl, please visit: http://perldoc.perl.org/perlre.html