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
No Match

r"
"
ms

Test String

Code Generator

Generated Code

#include <StringConstants.au3> ; to declare the Constants of StringRegExp #include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate Local $sRegex = "(?ms)<td width=\"70%\" class=\"tdbold\">\s+<div >\s*([^<&]+).*ที่อยู่\s+([^<&]+).*โทร.\s*([0-9๐-๙- ,]+)" Local $sString = "" & @CRLF & _ "<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">" & @CRLF & _ "<html xmlns="http://www.w3.org/1999/xhtml">" & @CRLF & _ " <head>" & @CRLF & _ " <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>" & @CRLF & _ "<script type="text/javascript">" & @CRLF & _ " var _gaq = _gaq || [];" & @CRLF & _ " _gaq.push(['_setAccount', 'UA-18733385-1']);" & @CRLF & _ " _gaq.push(['_trackPageview']);" & @CRLF & _ " (function() {" & @CRLF & _ " var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;" & @CRLF & _ " ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';" & @CRLF & _ " var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);" & @CRLF & _ " })();" & @CRLF & _ "</script>" & @CRLF & _ " <title>ระบบสารสนเทศภฺมิศาสตร์ทรัพยากรสุขภาพ สำนักงานสาธารณสุขจังหวัดสมุทรปราการ</title>" & @CRLF & _ " <script type="text/javascript" src="jquery/jquery-1.3.2.min.js"></script> " & @CRLF & _ " <script type="text/javascript" src="jquery/jquery.easing.1.3.js"></script> " & @CRLF & _ " <script type="text/javascript" src="jquery/jquery.galleryview-1.1.js"></script> " & @CRLF & _ " <script type="text/javascript" src="jquery/jquery.timers-1.1.2.js"></script> " & @CRLF & _ " <script type="text/javascript" src="js/jquery_slide.js"></script> " & @CRLF & _ " <link href="css/stylemap.css" rel="stylesheet" type="text/css">" & @CRLF & _ " <script type="text/javascript" src="../ckeditor/ckeditor.js"></script>" & @CRLF & _ " <script type="text/javascript">" & @CRLF & _ " //<![CDATA[" & @CRLF & _ " CKEDITOR.replace( 'message',{" & @CRLF & _ " height : 400," & @CRLF & _ " width : 400," & @CRLF & _ " } );" & @CRLF & _ " //]]>" & @CRLF & _ " </script>" & @CRLF & _ " <script type="text/javascript" src="highslide/highslide-with-gallery.js"></script>" & @CRLF & _ "<link rel="stylesheet" type="text/css" href="highslide/highslide.css" />" & @CRLF & _ "" & @CRLF & _ " <script type="text/javascript">" & @CRLF & _ " hs.graphicsDir = 'highslide/graphics/';" & @CRLF & _ " hs.align = 'center';" & @CRLF & _ " hs.transitions = ['expand', 'crossfade'];" & @CRLF & _ " hs.outlineType = 'glossy-dark';" & @CRLF & _ " hs.wrapperClassName = 'dark';" & @CRLF & _ " hs.fadeInOut = true;" & @CRLF & _ "" & @CRLF & _ " if (hs.addSlideshow) hs.addSlideshow({" & @CRLF & _ " interval: 4000," & @CRLF & _ " repeat: false," & @CRLF & _ " useControls: true," & @CRLF & _ " fixedControls: 'fit'," & @CRLF & _ " overlayOptions: {" & @CRLF & _ " opacity: .6," & @CRLF & _ " position: 'bottom center'," & @CRLF & _ " hideOnMouseOut: true}" & @CRLF & _ " });" & @CRLF & _ "" & @CRLF & _ "</script>" & @CRLF & _ " </head>" & @CRLF & _ "<body>" & @CRLF & _ "" & @CRLF & _ "<table align ="center" width="760" cellpadding="0" cellspacing="0"><tr><td>" & @CRLF & _ "<div id="navcontainer">" & @CRLF & _ " <ul id="navlist">" & @CRLF & _ " <!-- CSS Tabs -->" & @CRLF & _ " " & @CRLF & _ "<li><a href="info.php?maincode=00001" id="current">ข้อมูลทั่วไป</a></li>" & @CRLF & _ "<li><a href="infopersonal.php?maincode=00001">ข้อมูลบุคลากร</a></li>" & @CRLF & _ "<li><a href="infospecialty.php?maincode=00001">แพทย์เฉพาะทาง</a></li>" & @CRLF & _ "<li><a href="infoequip.php?maincode=00001">สถานที่และเครื่องมือแพทย์</a></li>" & @CRLF & _ "<li><a href="work.php?maincode=00001">ผลงานเด่น</a></li>" & @CRLF & _ "<li><a href="login.php?maincode=00001">เข้าสู่ระบบ</a></li>" & @CRLF & _ "" & @CRLF & _ " </ul>" & @CRLF & _ " </div>" & @CRLF & _ " " & @CRLF & _ "</td></tr></table>" & @CRLF & _ "<!--table width="761" align="center" class="tableBorder">" & @CRLF & _ "<tr>" & @CRLF & _ "<td width="753"-->" & @CRLF & _ "<table width="650" align="center" bgcolor="#FFFFFF" cellpadding="0" cellspacing="0">" & @CRLF & _ " <tr>" & @CRLF & _ " <td colspan="2" class="tdhead650" valign="middle">ข้อมูลทั่วไป สำนักงานสาธารณสุขจังหวัดสมุทรปราการ</td>" & @CRLF & _ " </tr>" & @CRLF & _ " <tr>" & @CRLF & _ " <td width="30%">&nbsp;</td>" & @CRLF & _ " <td width="70%">&nbsp;</td>" & @CRLF & _ " </tr>" & @CRLF & _ " <tr>" & @CRLF & _ " <td align="center" valign="top"> <div class="highslide-gallery"> <a href="upload/logo/p_00001_190418_031102.png" class="highslide" onclick="return hs.expand(this)">" & @CRLF & _ "<img src="upload/logo/p_00001_190418_031102.png" alt="Highslide JS"title="Click to enlarge" width="100" height="100"/></a>" & @CRLF & _ "<div class="highslide-caption"><center> สำนักงานสาธารณสุขจังหวัดสมุทรปราการ</center></div></td>" & @CRLF & _ " <td width="70%" class="tdbold">" & @CRLF & _ " <div > สำนักงานสาธารณสุขจังหวัดสมุทรปราการ&nbsp;&nbsp;<a href="gmap.php?code=00001" target="_blank"><img src="image_res/2green.png" title="แสดงในแผนที่" border="0"/></a></div><br />" & @CRLF & _ " <div> รหัส 00001</div><br />" & @CRLF & _ " <div>ที่อยู่ 19 ซอย 35 อัศวนนท์ 2 ถ.สุขุมวิท ต.ปากน้ำ อ.เมือง จ.สมุทรปราการ 10270 </div><br />" & @CRLF & _ " <div>ที่ตั้ง จ.สมุทรปราการ อ.เมืองสมุทรปราการ ต.ปากน้ำ หมู่ 0 </div> " & @CRLF & _ " <br>" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ " " & @CRLF & _ " <div>โทร. 02-3895980&nbsp;&nbsp; แฟกซ์ 02-3951034 </div>" & @CRLF & _ "<br> " & @CRLF & _ "" & @CRLF & _ " " & @CRLF & _ " <div>อีเมล์ -&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; เว็บไซต์ <a href="http://www.spko.moph.go.th/" target="_new" >www.spko.moph.go.th/</a></div></td>" & @CRLF & _ " </tr>" & @CRLF & _ " <tr>" & @CRLF & _ " <td>&nbsp;</td>" & @CRLF & _ " <td></td>" & @CRLF & _ " </tr>" & @CRLF & _ " <tr>" & @CRLF & _ " <td>&nbsp;</td>" & @CRLF & _ " <td class="trBottom">ผู้บริหารและประวัติสถานพยาบาล</td>" & @CRLF & _ " </tr>" & @CRLF & _ " <tr>" & @CRLF & _ " <td align="center"> <div class="highslide-gallery"> <a href="upload/ceo/p_00001_140218_134154.jpg" class="highslide" onclick="return hs.expand(this)">" & @CRLF & _ "<img src="upload/ceo/p_00001_140218_134154.jpg" alt="Highslide JS"title="Click to enlarge" width="100" height="100"/></a>" & @CRLF & _ "<div class="highslide-caption"><center> สำนักงานสาธารณสุขจังหวัดสมุทรปราการ</center></div></td>" & @CRLF & _ " <td><br ><br />" & @CRLF & _ " <div >ชื่อผู้บริหาร <b>&nbsp;นพ.สวัสดิ์ อภิวัจนีวงศ์</b></div>" & @CRLF & _ " <br />" & @CRLF & _ " <div >" & @CRLF & _ " ประวัติสถานพยาบาล" & @CRLF & _ "<a href="info_history.php?maincode=00001" title="อ่านประวัติสถานพยาบาล"><b>เพิ่มเติม</b></a> <p>&nbsp;</p>" & @CRLF & _ "" & @CRLF & _ " " & @CRLF & _ " </div>" & @CRLF & _ " </td>" & @CRLF & _ " </tr>" & @CRLF & _ " <tr>" & @CRLF & _ " <td>&nbsp;</td>" & @CRLF & _ " <td></td>" & @CRLF & _ " </tr>" & @CRLF & _ " " & @CRLF & _ " " & @CRLF & _ "</table>" & @CRLF & _ "<table align="center">" & @CRLF & _ "<tr>" & @CRLF & _ "<td>" & @CRLF & _ "<body><div class="highslide-gallery">" & @CRLF & _ "" & @CRLF & _ " " & @CRLF & _ " <a href="upload/hospital/p_00001_190418_024043.jpg" class="highslide" onClick="return hs.expand(this)">" & @CRLF & _ "<img src="upload/hospital/p_00001_190418_024043.jpg" alt="Highslide JS"title="Click to enlarge" width="133" height="100"/></a>" & @CRLF & _ "<div class="highslide-caption"><center> สำนักงานสาธารณสุขจังหวัดสมุทรปราการ</center></div>" & @CRLF & _ " " & @CRLF & _ " <a href="upload/hospital/p_00001_190418_024156.jpg" class="highslide" onClick="return hs.expand(this)">" & @CRLF & _ "<img src="upload/hospital/p_00001_190418_024156.jpg" alt="Highslide JS"title="Click to enlarge" width="133" height="100"/></a>" & @CRLF & _ "<div class="highslide-caption"><center> สำนักงานสาธารณสุขจังหวัดสมุทรปราการ</center></div>" & @CRLF & _ " " & @CRLF & _ " <a href="upload/hospital/p_00001_190418_024306.jpg" class="highslide" onClick="return hs.expand(this)">" & @CRLF & _ "<img src="upload/hospital/p_00001_190418_024306.jpg" alt="Highslide JS"title="Click to enlarge" width="133" height="100"/></a>" & @CRLF & _ "<div class="highslide-caption"><center> สำนักงานสาธารณสุขจังหวัดสมุทรปราการ</center></div>" & @CRLF & _ " " & @CRLF & _ " <a href="upload/hospital/p_00001_190418_025428.jpg" class="highslide" onClick="return hs.expand(this)">" & @CRLF & _ "<img src="upload/hospital/p_00001_190418_025428.jpg" alt="Highslide JS"title="Click to enlarge" width="133" height="100"/></a>" & @CRLF & _ "<div class="highslide-caption"><center> สำนักงานสาธารณสุขจังหวัดสมุทรปราการ</center></div>" & @CRLF & _ " <br>" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "</div>" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "</div>" & @CRLF & _ "</body>" & @CRLF & _ "</td>" & @CRLF & _ "</tr>" & @CRLF & _ "</table>" & @CRLF & _ "" & @CRLF & _ "<table width="650" align="center" cellpadding="0" cellspacing="0">" & @CRLF & _ "<tr>" & @CRLF & _ " <td align="right" class="trBottom">&nbsp;</td>" & @CRLF & _ " </tr>" & @CRLF & _ " <tr>" & @CRLF & _ " <td align="right" >ข้อมูลวันที่ 6 ธ.ค. 2562 15:51</td>" & @CRLF & _ " </tr>" & @CRLF & _ "</table>" & @CRLF & _ "<!--/td></tr></table-->" & @CRLF & _ "<TABLE border ='0' width ="650" align="center">" & @CRLF & _ "<tr><td>&nbsp;</td></tr>" & @CRLF & _ "<TR><TD width =100% align= "center"><a href="https://play.google.com/store/apps/details?id=com.hiso.hisomap4" target="_blank"><img src="app_android.png" alt="ดาวน์โหลดได้ที่ Google Play"/></a><!-- Begin ShinyStat Free code -->" & @CRLF & _ "<script type="text/javascript" language="JavaScript" src="http://codice.shinystat.com/cgi-bin/getcod.cgi?USER=healthHiso"></script>" & @CRLF & _ "<noscript>" & @CRLF & _ "<a href="http://www.shinystat.com" target="_top">" & @CRLF & _ "<img src="http://www.shinystat.com/cgi-bin/shinystat.cgi?USER=healthHiso" alt="Free hit counter" border="0" /></a>" & @CRLF & _ "</noscript><a href="https://itunes.apple.com/th/app/gis-health/id859027531?mt=8" target="_blank"><img src="app_ios.png" alt="ดาวน์โหลดได้ที่ App Store"/></a>" & @CRLF & _ "</TD><TD></TD></TR>" & @CRLF & _ "</TABLE>" & @CRLF & _ "</body>" & @CRLF & _ "</html>" Local $aArray = StringRegExp($sString, $sRegex, $STR_REGEXPARRAYFULLMATCH) ; Present the entire match result _ArrayDisplay($aArray, "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 AutoIt, please visit: https://www.autoitscript.com/autoit3/docs/functions/StringRegExp.htm