Regular Expressions 101

Save & Share

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

/
/
gm

Test String

Code Generator

Generated Code

$re = '/AB\s+-\s+((.*\s*)*?)(?:[A-Z]{2}\s+-\s)\K/m'; $str = 'AB - The new virus SARS-CoV-2 is savagely spreading out over the world. The biologic studies show that the target receptor for the virus might be angiotensin-converting enzyme 2 (ACE2). This peptide is responsible for converting angiotensin II (Ang II), which is a profoundly active peptide, into Ang 1-7 with quite a balancing barbell function. It is emphasized that the direct target of the virus is ACE2 underlining the obvious difference with ACE. Nevertheless, we hypothesized that a backload build-up effect on Ang II may usurp the ACE capacity and subsequently leave the bradykinin system unabated. CN - Gemelli Against COVID-19 Post-Acute Care Study Group LA - eng PT - Journal Article DEP - 20200611 TA - Aging Clin Exp Res JT - Aging clinical and experimental research JID - 101132995 SB - IM PMC - PMC7287410 OTO - NOTNLM OT - COVID-19 OT - Health care organization AB - OBJECTIVE: The clinical manifestations of COVID-19 run from asymptomatic disease to severe acute respiratory syndrome. Older age and comorbidities are associated to more severe disease. A role of obesity is suspected. METHODS: We enrolled patients hospitalized in the medical COVID-19 ward with SARS-CoV-2 related pneumonia. Primary outcome of the study was to assess the relationship between the severity of COVID-19 and obesity classes according to BMI. RESULTS: 92 patients (61.9% males; age 70.5±13.3 years) were enrolled. Patients with overweight and obesity were younger than normal-weight patients (68.0±12.6 and 67.0±12.6 years vs. 76.1±13.0 years, p<0.01). A higher need for assisted ventilation beyond pure oxygen support (Invasive Mechanical Ventilation or Non-Invasive Ventilation) and a higher admission to intensive or semi-intensive care units was observed in patients with overweight and obesity (p<0.01 and p < 0.05, respectively) even after adjusting for sex, age and comorbidities (p<0.05 and p<0.001, respectively), or when patients with dementia or advanced cancer were removed from the analysis (p<0.05). CONCLUSION: Patients with overweight and obesity admitted in a medical ward for SARS-CoV-2 related pneumonia, despite their younger age, required more frequently assisted ventilation and access to intensive or semi-intensive care units than normal weight patients. CI - This article is protected by copyright. All rights reserved. FAU - Busetto, Luca AU - Busetto L AUID- ORCID: 0000-0003-4883-8980 AD - Department of Medicine, University of Padova, Padova, Italy. AD - Center for the Study and the Integrated Management of Obesity, Padova University Hospital, Padova, Italy. FAU - Bettini, Silvia AU - Bettini S AD - Department of Medicine, University of Padova, Padova, Italy. FAU - Fabris, Roberto AU - Fabris R AD - Center for the Study and the Integrated Management of Obesity, Padova University Hospital, Padova, Italy. FAU - Serra, Roberto AU - Serra R AD - Center for the Study and the Integrated Management of Obesity, Padova University Hospital, Padova, Italy. FAU - Dal Pra\', Chiara AU - Dal Pra\' C AD - Center for the Study and the Integrated Management of Obesity, Padova University Hospital, Padova, Italy. FAU - Maffei, Pietro AU - Maffei P AD - Center for the Study and the Integrated Management of Obesity, Padova University Hospital, Padova, Italy. FAU - Rossato, Marco AU - Rossato M AD - Department of Medicine, University of Padova, Padova, Italy. AD - Center for the Study and the Integrated Management of Obesity, Padova University Hospital, Padova, Italy. FAU - Fioretto, Paola AU - Fioretto P AD - Department of Medicine, University of Padova, Padova, Italy. AD - Center for the Study and the Integrated Management of Obesity, Padova University Hospital, Padova, Italy. FAU - Vettor, Roberto AU - Vettor R AD - Department of Medicine, University of Padova, Padova, Italy. AD - Center for the Study and the Integrated Management of Obesity, Padova University Hospital, Padova, Italy. LA - eng PT - Journal Article DEP - 20200528 TA - Obesity (Silver Spring) JT - Obesity (Silver Spring, Md.) JID - 101264860 SB - IM PMC - PMC7283686 OTO - NOTNLM OT - COVID-19 OT - SARS-CoV-2 OT - obesity EDAT- 2020/05/29 06:00 MHDA- 2020/05/29 06:00 CRDT- 2020/05/29 06:00 PHST- 2020/05/29 06:00 [entrez] PHST- 2020/05/29 06:00 [pubmed] PHST- 2020/05/29 06:00 [medline] AID - OBY22918 [pii] AID - 10.1002/oby.22918 [doi] PST - aheadofprint SO - Obesity (Silver Spring). 2020 May 28:10.1002/oby.22918. doi: 10.1002/oby.22918. PMID- 32463543 OWN - NLM STAT- Publisher LR - 20200528 IS - 1879-0844 (Electronic) IS - 1388-9842 (Linking) DP - 2020 May 28 TI - Management of Heart Failure Patients with COVID-19. A Joint Position Paper of the Chinese Heart Failure Association & National Heart Failure Committee and the Heart Failure Association of the European Society of Cardiology. LID - 10.1002/ejhf.1915 [doi] AB - The Coronavirus Disease 2019 (COVID-19) pandemic of severe acute respiratory syndrome coronavirus 2 (SARS-CoV-2) infection is causing considerable morbidity and mortality worldwide. Multiple reports have suggested that patients with heart failure (HF) are at a higher risk of severe disease and mortality with COVID-19. Moreover, evaluating and treating HF patients with comorbid COVID-19 represents a formidable clinical challenge as symptoms of both conditions may overlap and they may potentiate each other. Limited data exist regarding comprehensive management of HF patients with concomitant COVID-19. Since these issues pose serious new challenges for clinicians worldwide, HF specialists must develop a structured approach to the care of patients with COVID-19 and be included early in the care of these patients. Therefore, the Heart Failure Association of the European Society of Cardiology and Chinese Heart Failure Association & National Heart Failure Committee conducted web-based meetings to discuss these unique clinical challenges and reach a consensus opinion to help providers worldwide deliver better patient care. The main objective of this position paper is to outline the management of HF patients with concomitant COVID-19 based on the available data and personal experiences of physicians from Asia, Europe and United States. This article is protected by copyright. All rights reserved. CI - This article is protected by copyright. All rights reserved. FAU - Zhang, Yuhui AU - Zhang Y AD - Heart Failure Center, State Key Laboratory of Cardiovascular Disease, Fuwai Hospital, National Center for Cardiovascular Diseases, Chinese Academy of Medical Sciences & Peking Union Medical College, Beijing, 100037, China. FAU - Stewart Coats, Andrew J AU - Stewart Coats AJ AD - Department of Cardiology, IRCCS San Raffaele Pisana, Rome, Italy. FAU - Zheng, Zhe AU - Zheng Z AD - Department of Cardiovascular Surgery, State Key Laboratory of Cardiovascular Disease, Fuwai Hospital, National Center for Cardiovascular Diseases, Chinese Academy of Medical Sciences & Peking Union Medical College, Beijing, 100037, China. FAU - Adamo, Marianna AU - Adamo M AD - Cardiology, ASST Spedali Civili di Brescia and Department of Medical and Surgical Specialties, Radiological Sciences, and Public Health, University of Brescia, Brescia, Italy. FAU - Ambrosio, Giuseppe AU - Ambrosio G AD - Division of Cardiology, University of Perugia School of Medicine, Perugia, Italy. FAU - Anker, Stefan D AU - Anker SD AD - Department of Cardiology (CVK); and Berlin Institute of Health Center for Regenerative Therapies (BCRT), German Centre for Cardiovascular Research (DZHK) partner site Berlin; Charité Universitätsmedizin Berlin, Germany. FAU - Butler, Javed AU - Butler J AD - Department of Medicine, University of Mississippi Medical Center, Jackson, MS, USA. FAU - Xu, Dingli AU - Xu D AD - Key Laboratory for Organ Failure Research, Department of Cardiology, Nanfang Hospital, Southern Medical University, Guangzhou, China. Guangzhou Regenerative Medicine and Health Guangdong Laboratory, Guangzhou, 510515, China. FAU - Mao, Jingyuan AU - Mao J AD - First Teaching Hospital of Tianjin University of Traditional Chinese Medicine, Tianjin, 300193, China. FAU - Khan, Muhammad Shahzeb AU - Khan MS AD - Department of Medicine, Cook County Hospital, Chicago, IL, USA. FAU - Bai, Ling AU - Bai L AD - Department of Cardiovascular Medicine, The First Affiliated Hospital of Xi\'an Jiaotong University, Xi\'an, 710061, China. FAU - Mebazaa, Alexandre AU - Mebazaa A AD - Université de Paris, Paris, France; U942 Inserm - MASCOT and Department of Anaesthesia and Critical Care, University Hospitals Saint Louis-Lariboisière, APHP, Paris, France. FAU - Ponikowski, Piotr AU - Ponikowski P AD - Department of Heart Diseases, Medical University, Military Hospital, Wrocław, Poland. FAU - Tang, Qizhu AU - Tang Q AD - Department of Cardiology, Renmin Hospital of Wuhan University, Cardiovascular Research Institute, Wuhan University, Hubei, Key Laboratory of Cardiology, Wuhan, 430060, China. FAU - Ruschitzka, Frank AU - Ruschitzka F AD - University Heart Centre, University Hospital Zurich, Zurich, Switzerland. FAU - Seferovic, Petar AU - Seferovic P AD - Clinic of Endocrinology, Diabetes and Metabolic Diseases, Belgrade University Medical Center, Belgrade, Serbia. FAU - Tschöpe, Carsten AU - Tschöpe C AD - Department of Cardiology, Campus Virchow Klinikum, Charite - Universitaetsmedizin Berlin, Berlin, Germany. FAU - Zhang, Shuyang AU - Zhang S AD - Department of Cardiology, Peking Union Medical College & Chinese Academy of Medical Science, Peking Union Medical College Hospital, No. 1 Shuai Fu Yuan, Beijing, 100730, China. FAU - Gao, Chuanyu AU - Gao C AD - Department of Cardiology, Henan Provincial People\'s Hospital; Fuwai Central China Cardiovascular Hospital, Zhengzhou, 45003, China. FAU - Zhou, Shenghua AU - Zhou S AD - Department of Cardiology, The Second Xiangya Hospital of Central South University, Changsha, 410011, China. FAU - Senni, Michele AU - Senni M AD - Cardiology Division, Cardiovascular Department, Papa Giovanni XXIII Hospital, Bergamo, Italy. FAU - Zhang, Jian AU - Zhang J AD - Heart Failure Center, State Key Laboratory of Cardiovascular Disease, Fuwai Hospital, National Center for Cardiovascular Diseases, Chinese Academy of Medical Sciences & Peking Union Medical College, Beijing, 100037, China. FAU - Metra, Marco AU - Metra M AD - Cardiology, ASST Spedali Civili di Brescia and Department of Medical and Surgical Specialties, Radiological Sciences, and Public Health, University of Brescia, Brescia, Italy. LA - eng PT - Journal Article DEP - 20200528 PL - England TA - Eur J Heart Fail JT - European journal of heart failure JID - 100887595 SB - IM OTO - NOTNLM OT - COVID-19 OT - Coronavirus OT - Diagnosis OT - Heart failure OT - Management OT - SARS-COV2 EDAT- 2020/05/29 06:00 MHDA- 2020/05/29 06:00 CRDT- 2020/05/29 06:00 PHST- 2020/05/14 00:00 [received] PHST- 2020/05/22 00:00 [revised] PHST- 2020/05/24 00:00 [accepted] PHST- 2020/05/29 06:00 [entrez] PHST- 2020/05/29 06:00 [pubmed] PHST- 2020/05/29 06:00 [medline] AID - 10.1002/ejhf.1915 [doi] PST - aheadofprint SO - Eur J Heart Fail. 2020 May 28. doi: 10.1002/ejhf.1915. PMID- 32463530 OWN - NLM STAT- Publisher LR - 20200611 IS - 1930-739X (Electronic) IS - 1930-7381 (Print) IS - 1930-7381 (Linking) DP - 2020 May 28 TI - Screen time for children and adolescents during the COVID-19 pandemic. LID - 10.1002/oby.22917 [doi] AB - The coronavirus 2019 (COVID-19) pandemic has led to laws and policies including national school closures, lockdown or shelter in place laws, and social distancing recommendations that may translate to higher overall screen time among children and adolescents for the duration of these laws and policies. These policies may need to be periodically re-instated to control future COVID-19 recurrences or other national emergencies. Excessive screen time is associated with cardiovascular disease risk factors such as obesity, high blood pressure, and insulin resistance because it increases sedentary time and is associated with snacking. CI - This article is protected by copyright. All rights reserved. FAU - Nagata, Jason M AU - Nagata JM AD - Department of Pediatrics, University of California, San Francisco, San Francisco, CA, USA. FAU - Abdel Magid, Hoda S AU - Abdel Magid HS AD - Department of Epidemiology and Population Health, Stanford University, Stanford, CA, USA. FAU - Gabriel, Kelley Pettee AU - Gabriel KP AD - Department of Epidemiology, University of Alabama at Birmingham, Birmingham, AL, USA. LA - eng PT - Journal Article DEP - 20200528 TA - Obesity (Silver Spring) JT - Obesity (Silver Spring, Md.) JID - 101264860 SB - IM PMC - PMC7283714 EDAT- 2020/05/29 06:00 MHDA- 2020/05/29 06:00 CRDT- 2020/05/29 06:00 PHST- 2020/05/29 06:00 [entrez] PHST- 2020/05/29 06:00 [pubmed] PHST- 2020/05/29 06:00 [medline] AID - OBY22917 [pii] AID - 10.1002/oby.22917 [doi] PST - aheadofprint SO - Obesity (Silver Spring). 2020 May 28:10.1002/oby.22917. doi: 10.1002/oby.22917. PMID- 32463522 OWN - NLM STAT- Publisher LR - 20200611 IS - 1365-2044 (Electronic) IS - 0003-2409 (Print) IS - 0003-2409 (Linking) DP - 2020 May 28 TI - Managing the R0 of Covid-19: mathematics fights back. LID - 10.1111/anae.15151 [doi] AB - Perhaps for the first time in history, a single statistical measure is now dictating the entirety of UK government policy. The \'basic reproduction number\', R0 value for Covid-19 is more directly determining economic and social policy than has ever the inflation rate, interest rate, or exchange rate. It is encouraging to see political policy for once \'rational\' but disappointing it took a pandemic to make it so. However, is R0 an appropriate and significant measure? Like many mathematics/statistical parameters, R0 is relatively easy to explain, more complicated to understand (even graphically), and very difficult to calculate, or use for modelling. Given its significance for all our lives, it is important to understand a little of its background. This article seeks to explain the issues in a non-technical way, relegating all equations (used sparingly) to appendices. CI - This article is protected by copyright. All rights reserved. FAU - Pandit, J J AU - Pandit JJ AD - Consultant Anaesthetist, Nuffield Department of Anaesthetics, Oxford University Hospitals Foundation Trust, Oxford, OX3 9DU, United Kingdom. LA - eng PT - Journal Article DEP - 20200528 TA - Anaesthesia JT - Anaesthesia JID - 0370524 SB - AIM SB - IM PMC - PMC7283796 EDAT- 2020/05/29 06:00 MHDA- 2020/05/29 06:00 CRDT- 2020/05/29 06:00 PHST- 2020/05/29 06:00 [entrez] PHST- 2020/05/29 06:00 [pubmed] PHST- 2020/05/29 06:00 [medline] AID - ANAE15151 [pii]'; 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