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

#include <StringConstants.au3> ; to declare the Constants of StringRegExp #include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate Local $sRegex = ">Temperature<.*\n.*>(.+?) °C<" Local $sString = "" & @CRLF & _ "<!doctype html>" & @CRLF & _ "<html lang="ru">" & @CRLF & _ "<head>" & @CRLF & _ " <meta charset="UTF-8">" & @CRLF & _ " <title>Текущая погода в Сокольниках, Москва. Архив погоды.</title>" & @CRLF & _ " <link rel="ICON" href="/favicon.ico">" & @CRLF & _ " <link rel="stylesheet" href="/css/reset.css">" & @CRLF & _ " <link rel="stylesheet" href="/css/styles-new.css">" & @CRLF & _ " <link rel="stylesheet" href="/css/bootstrap.min.css">" & @CRLF & _ " <link rel="stylesheet" type="text/css" href="https://s1.gismeteo.ua/static/css/informer2/gs_informerClient.min.css">" & @CRLF & _ " <meta name="viewport" content="width=device-width, initial-scale=1.0">" & @CRLF & _ "<script type="text/javascript" src="http://gc.kis.scr.kaspersky-labs.com/6533F8E7-1BF0-874B-8F28-D3F17F7C86D4/main.js" charset="UTF-8"></script></head>" & @CRLF & _ "<body>" & @CRLF & _ "<div class="container wrapper table page">" & @CRLF & _ " <div class="row cell" style="margin-top:10px">" & @CRLF & _ " <div class="col-md-12 places">" & @CRLF & _ " <div class="row">" & @CRLF & _ " <a href="/" class="col-md-3 col-xs-12">Выбор станции</a>" & @CRLF & _ " <a href="/prague" class="col-md-3 col-xs-12">Прага-Чехия</a>" & @CRLF & _ " <a href="/sheremetevo" class="col-md-3 col-xs-12">Москва-Шереметьево</a>" & @CRLF & _ " <a href="/sokolniki" class="active col-md-3 col-xs-12">Москва-Сокольники</a>" & @CRLF & _ " </div>" & @CRLF & _ " </div>" & @CRLF & _ " <div class="col-md-12 header-container">" & @CRLF & _ " <div class="col-md-4 col-lg-3">" & @CRLF & _ " <a href="/"><img class="logo" src="/images/Logo-sokolniki.png" alt="Текущая погода в Сокольниках, Москва."></a> </div>" & @CRLF & _ " <div class="col-md-8 col-lg-9">" & @CRLF & _ " <div class="row">" & @CRLF & _ " <ul>" & @CRLF & _ " <li class="active"><a href="/sokolniki">Текущие данные</a></li>" & @CRLF & _ " <li class=""><a href="/sokolniki/day.php">Данные за сутки</a></li>" & @CRLF & _ " <li class=""><a href="/sokolniki/week.php">Данные за неделю</a></li>" & @CRLF & _ " <li class=""><a href="/sokolniki/year.php">Данные за год</a></li>" & @CRLF & _ " <li class=""><a href="/sokolniki/last.php">Архивы прошлых лет</a></li>" & @CRLF & _ " </ul>" & @CRLF & _ " <div class="clear"></div>" & @CRLF & _ " <div class="col-md-12 descript-station">" & @CRLF & _ " Данные получены с помощью метеостанций DAVIS Vantage Pro2. </div>" & @CRLF & _ " </div>" & @CRLF & _ " </div>" & @CRLF & _ " </div><div class="col-md-12">" & @CRLF & _ " <div class="col-md-6"><p style="text-align: right; font-weight: bold;">Восход солнца: 8:53</p></div>" & @CRLF & _ " <div class="col-md-6"><p style="text-align: left; font-weight: bold;">Заход солнца: 15:59</p></div>" & @CRLF & _ " <p class="last-measure" style="font-style: italic;">Время последнего измерения: 15.12.16 0:13</p>" & @CRLF & _ " </div>" & @CRLF & _ " <div class="col-md-12">" & @CRLF & _ " <table class="table table-bordered table-hover meteo-table">" & @CRLF & _ " <tbody>" & @CRLF & _ " <tr>" & @CRLF & _ " <td><p style="font-weight: bold; font-style: italic;">Температура</p>" & @CRLF & _ " <p style="font-weight: bold;font-style: italic;color: #9A9A9A;">Temperature</p></td>" & @CRLF & _ " <td><b>-7.8 °C</b></td>" & @CRLF & _ " <td><p style="font-weight: bold; font-style: italic;">Точка росы</p>" & @CRLF & _ " <p style="font-weight: bold;font-style: italic;color: #9A9A9A;">Due point</p></td>" & @CRLF & _ " <td><b>-10.0 °C</b></td>" & @CRLF & _ " </tr>" & @CRLF & _ " <tr>" & @CRLF & _ " <td><p style="font-weight: bold; font-style: italic;">Влажность</p>" & @CRLF & _ " <p style="font-weight: bold;font-style: italic;color: #9A9A9A;">Humidity</p></td>" & @CRLF & _ " <td><b>84% </b></td>" & @CRLF & _ " <td><p style="font-weight: bold; font-style: italic;">Температура комфорта</p>" & @CRLF & _ " <p style="font-weight: bold;font-style: italic;color: #9A9A9A;">Comfort temperature</p></td>" & @CRLF & _ " <td><b>-9.1 °C</b></td>" & @CRLF & _ " </tr>" & @CRLF & _ " <tr>" & @CRLF & _ " <td><p style="font-weight: bold; font-style: italic;">Ветер</p>" & @CRLF & _ " <p style="font-weight: bold;font-style: italic;color: #9A9A9A;">Wind</p></td>" & @CRLF & _ " <td><b>E в 0.4 m/s</b></td>" & @CRLF & _ " <td><p style="font-weight: bold; font-style: italic;">THW индекс</p>" & @CRLF & _ " <p style="font-weight: bold;font-style: italic;color: #9A9A9A;">THW index</p></td>" & @CRLF & _ " <td><b>-9.2 °C</b></td>" & @CRLF & _ " </tr>" & @CRLF & _ " <tr>" & @CRLF & _ " <td><p style="font-weight: bold; font-style: italic;">Давление</p>" & @CRLF & _ " <p style="font-weight: bold;font-style: italic;color: #9A9A9A;">Air pressure</p></td>" & @CRLF & _ " <td><b>760.3 mm & Rising Rapidly</b></td>" & @CRLF & _ " <td><p style="font-weight: bold; font-style: italic;">Индекс тепла</p>" & @CRLF & _ " <p style="font-weight: bold;font-style: italic;color: #9A9A9A;">Heat index</p></td>" & @CRLF & _ " <td><b>-7.9 °C</b></td>" & @CRLF & _ " </tr>" & @CRLF & _ " <tr>" & @CRLF & _ " <td><p style="font-weight: bold; font-style: italic;">Осадки сегодня</p>" & @CRLF & _ " <p style="font-weight: bold;font-style: italic;color: #9A9A9A;">Rainfall today</p></td>" & @CRLF & _ " <td><b>0.0 mm</b></td>" & @CRLF & _ " <td><p style="font-weight: bold; font-style: italic;">Последние осадки</p>" & @CRLF & _ " <p style="font-weight: bold;font-style: italic;color: #9A9A9A;">Last rainfall</p></td>" & @CRLF & _ " <td><b>1.2 mm</b></td>" & @CRLF & _ " </tr>" & @CRLF & _ " <tr>" & @CRLF & _ " <td><p style="font-weight: bold; font-style: italic;">Осадки в месяце</p>" & @CRLF & _ " <p style="font-weight: bold;font-style: italic;color: #9A9A9A;">Rainfall this month</p></td>" & @CRLF & _ " <td><b>5.8 mm</b></td>" & @CRLF & _ " <td><p style="font-weight: bold; font-style: italic;">Годовые осадки</p>" & @CRLF & _ " <p style="font-weight: bold;font-style: italic;color: #9A9A9A;">Rainfall this year</p></td>" & @CRLF & _ " <td><b>355.8 mm</b></td>" & @CRLF & _ " </tr>" & @CRLF & _ " <tr>" & @CRLF & _ " <td><p style="font-weight: bold; font-style: italic;">Скорость текущих осадков</p>" & @CRLF & _ " <p style="font-weight: bold;font-style: italic;color: #9A9A9A;">Speed of the current rainfall</p></td>" & @CRLF & _ " <td><b>0.0 mm/hr</b></td>" & @CRLF & _ " <td><p style="font-weight: bold; font-style: italic;">Солнечное излучение</p>" & @CRLF & _ " <p style="font-weight: bold;font-style: italic;color: #9A9A9A;">Solar radiation</p></td>" & @CRLF & _ " <td><b>0 W/m?</b></td>" & @CRLF & _ " </tr>" & @CRLF & _ " <tr>" & @CRLF & _ " <td><p style="font-weight: bold; font-style: italic;">УФ индекс</p>" & @CRLF & _ " <p style="font-weight: bold;font-style: italic;color: #9A9A9A;">UV index</p></td>" & @CRLF & _ " <td><b>0.0 index</b></td>" & @CRLF & _ " <td></td>" & @CRLF & _ " <td></td>" & @CRLF & _ " </tr>" & @CRLF & _ " </tbody>" & @CRLF & _ " </table>" & @CRLF & _ " </div>" & @CRLF & _ " <div class="btns-weather">" & @CRLF & _ " <a href='dataNOAA/downld02.txt' class="grafic-btn">Табличные данные<br>за два дня</a>" & @CRLF & _ " <a href='dataNOAA/NOAAMO.TXT' class="grafic-btn">Отчёт N0AA<br>за текущий месяц</a>" & @CRLF & _ " <a href="day.php" class="grafic-btn">Посмотреть <br> графики</a>" & @CRLF & _ " <a href='dataNOAA/NOAAPRMO.TXT' class="grafic-btn">Отчёт N0AA<br>за прошлый месяц</a>" & @CRLF & _ " <a href='dataNOAA/downld08.txt' class="grafic-btn">Табличные данные<br>за неделю</a>" & @CRLF & _ " </div>" & @CRLF & _ " <div class="col-md-12 footer" style="padding-top: 20px;">" & @CRLF & _ " <div class="row">" & @CRLF & _ " <div class="col-md-12 col-sm-12 i-home">" & @CRLF & _ " <div class="col-md-3 col-sm-3 informer">" & @CRLF & _ " <div class="row" style="margin:5px">" & @CRLF & _ "<!-- Gismeteo informer START -->" & @CRLF & _ "<link rel="stylesheet" type="text/css" href="https://bst1.gismeteo.ru/assets/flat-ui/legacy/css/informer.min.css">" & @CRLF & _ "<div id="gsInformerID-PEq6S8DHuRG6jf" class="gsInformer" style="width:239px;height:103px">" & @CRLF & _ " <div class="gsIContent">" & @CRLF & _ " <div id="cityLink">" & @CRLF & _ " <a href="https://www.gismeteo.ru/city/daily/4368/" target="_blank">Погода в Москве</a>" & @CRLF & _ " </div>" & @CRLF & _ " <div class="gsLinks">" & @CRLF & _ " <table>" & @CRLF & _ " <tr>" & @CRLF & _ " <td>" & @CRLF & _ " <div class="leftCol">" & @CRLF & _ " <a href="https://www.gismeteo.ru/" target="_blank">" & @CRLF & _ " <img alt="Gismeteo" title="Gismeteo" src="https://bst1.gismeteo.ru/assets/flat-ui/img/logo-mini2.png" align="middle" border="0" />" & @CRLF & _ " <span>Gismeteo</span>" & @CRLF & _ " </a>" & @CRLF & _ " </div>" & @CRLF & _ " <div class="rightCol">" & @CRLF & _ " <a href="https://www.gismeteo.ru/city/weekly/4368/" target="_blank">Прогноз на 2 недели</a>" & @CRLF & _ " </div>" & @CRLF & _ " </td>" & @CRLF & _ " </tr>" & @CRLF & _ " </table>" & @CRLF & _ " </div>" & @CRLF & _ " </div>" & @CRLF & _ "</div>" & @CRLF & _ "<script async src="https://www.gismeteo.ru/api/informer/getinformer/?hash=PEq6S8DHuRG6jf" type="text/javascript"></script>" & @CRLF & _ "<!-- Gismeteo informer END -->" & @CRLF & _ " </div>" & @CRLF & _ " </div>" & @CRLF & _ " <div class="col-md-9 col-sm-9">" & @CRLF & _ "" & @CRLF & _ "<div class="row" style="background: #337AB7; height: 97px;"><div style="border-radius: 0 0 0 25px;background: #FFFFFF;height: 55px;"></div><h4>Сайт выполнен для <a href="http://aragonia.com" style="color:#ccc">Aragonia Group</a></h4></div>" & @CRLF & _ " </div>" & @CRLF & _ " </div>" & @CRLF & _ " </div>" & @CRLF & _ " </div>" & @CRLF & _ " </div>" & @CRLF & _ "<div style="text-align:center">" & @CRLF & _ "<div style="display:none">" & @CRLF & _ "<!-- SpyLOG f:0211 -->" & @CRLF & _ "<script language="javascript"><!--" & @CRLF & _ "Mu="u6009.69.spylog.com";Md=document;Mnv=navigator;Mp=0;" & @CRLF & _ "Md.cookie="b=b";Mc=0;if(Md.cookie)Mc=1;Mrn=Math.random();" & @CRLF & _ "Mn=(Mnv.appName.substring(0,2)=="Mi")?0:1;Mt=(new Date()).getTimezoneOffset();" & @CRLF & _ "Mz="p="+Mp+"&rn="+Mrn+"&c="+Mc+"&t="+Mt;" & @CRLF & _ "if(self!=top){Mfr=1;}else{Mfr=0;}Msl="1.0";" & @CRLF & _ "//--></script><script language="javascript1.1"><!--" & @CRLF & _ "Mpl="";Msl="1.1";Mj = (Mnv.javaEnabled()?"Y":"N");Mz+='&j='+Mj;" & @CRLF & _ "//--></script><script language="javascript1.2"><!--" & @CRLF & _ "Msl="1.2";Ms=screen;Mpx=(Mn==0)?Ms.colorDepth:Ms.pixelDepth;" & @CRLF & _ "Mz+="&wh="+Ms.width+'x'+Ms.height+"&px="+Mpx;" & @CRLF & _ "//--></script><script language="javascript1.3"><!--" & @CRLF & _ "Msl="1.3";//--></script><script language="javascript"><!--" & @CRLF & _ "My="";My+="<a href='http://"+Mu+"/cnt?cid=600969&f=3&p="+Mp+"&rn="+Mrn+"' target='_blank'>";" & @CRLF & _ "My+="<img src='http://"+Mu+"/cnt?cid=600969&"+Mz+"&sl="+Msl+"&r="+escape(Md.referrer)+"&fr="+Mfr+"&pg="+escape(window.location.href);" & @CRLF & _ "My+="' border=0 width=88 height=31 alt='SpyLOG'>";" & @CRLF & _ "My+="</a>";Md.write(My);//--></script><noscript>" & @CRLF & _ "<a href="http://u6009.69.spylog.com/cnt?cid=600969&f=3&p=0" target="_blank">" & @CRLF & _ "<img src="http://u6009.69.spylog.com/cnt?cid=600969&p=0" alt='SpyLOG' border='0' width=88 height=31 >" & @CRLF & _ "</a></noscript>" & @CRLF & _ "<!-- SpyLOG -->" & @CRLF & _ "</div>" & @CRLF & _ "" & @CRLF & _ "<!-- HotLog -->" & @CRLF & _ "<span id="hotlog_counter"></span>" & @CRLF & _ "<span id="hotlog_dyn"></span>" & @CRLF & _ "<script type="text/javascript">" & @CRLF & _ "var hot_s = document.createElement('script');" & @CRLF & _ "hot_s.type = 'text/javascript'; hot_s.async = true;" & @CRLF & _ "hot_s.src = 'http://js.hotlog.ru/dcounter/427664.js';" & @CRLF & _ "hot_d = document.getElementById('hotlog_dyn');" & @CRLF & _ "hot_d.appendChild(hot_s);" & @CRLF & _ "</script>" & @CRLF & _ "<noscript>" & @CRLF & _ "<a href="http://click.hotlog.ru/?427664" target="_blank"><img" & @CRLF & _ "src="http://hit23.hotlog.ru/cgi-bin/hotlog/count?s=427664&amp;im=303" border="0"" & @CRLF & _ "alt="HotLog"></a>" & @CRLF & _ "</noscript>" & @CRLF & _ "<!-- /HotLog -->" & @CRLF & _ "" & @CRLF & _ "<!-- Yandex.Metrika informer -->" & @CRLF & _ "<a href="https://metrika.yandex.ru/stat/?id=36081945&amp;from=informer"" & @CRLF & _ "target="_blank" rel="nofollow"><img src="https://informer.yandex.ru/informer/36081945/3_1_ECECECFF_CCCCCCFF_0_uniques"" & @CRLF & _ "style="width:88px; height:31px; border:0;" alt="Яндекс.Метрика" title="Яндекс.Метрика: данные за сегодня (просмотры, визиты и уникальные посетители)" onclick="try{Ya.Metrika.informer({i:this,id:36081945,lang:'ru'});return false}catch(e){}" /></a>" & @CRLF & _ "<!-- /Yandex.Metrika informer -->" & @CRLF & _ "" & @CRLF & _ "<!-- Yandex.Metrika counter -->" & @CRLF & _ "<script type="text/javascript">" & @CRLF & _ " (function (d, w, c) {" & @CRLF & _ " (w[c] = w[c] || []).push(function() {" & @CRLF & _ " try {" & @CRLF & _ " w.yaCounter36081945 = new Ya.Metrika({" & @CRLF & _ " id:36081945," & @CRLF & _ " clickmap:true," & @CRLF & _ " trackLinks:true," & @CRLF & _ " accurateTrackBounce:true" & @CRLF & _ " });" & @CRLF & _ " } catch(e) { }" & @CRLF & _ " });" & @CRLF & _ "" & @CRLF & _ " var n = d.getElementsByTagName("script")[0]," & @CRLF & _ " s = d.createElement("script")," & @CRLF & _ " f = function () { n.parentNode.insertBefore(s, n); };" & @CRLF & _ " s.type = "text/javascript";" & @CRLF & _ " s.async = true;" & @CRLF & _ " s.src = "https://mc.yandex.ru/metrika/watch.js";" & @CRLF & _ "" & @CRLF & _ " if (w.opera == "[object Opera]") {" & @CRLF & _ " d.addEventListener("DOMContentLoaded", f, false);" & @CRLF & _ " } else { f(); }" & @CRLF & _ " })(document, window, "yandex_metrika_callbacks");" & @CRLF & _ "</script>" & @CRLF & _ "<noscript><div><img src="https://mc.yandex.ru/watch/36081945" style="position:absolute; left:-9999px;" alt="" /></div></noscript>" & @CRLF & _ "<!-- /Yandex.Metrika counter -->" & @CRLF & _ "</div>" & @CRLF & _ "</div>" & @CRLF & _ "<script src="/js/jquery-2.1.1.js"></script>" & @CRLF & _ "<script src="/js/bootstrap.min.js"></script>" & @CRLF & _ "<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>" & @CRLF & _ "<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.3/jquery.easing.min.js"></script>" & @CRLF & _ "<script src="//cdn.jsdelivr.net/stickynavbar.js/1.3.2/jquery.stickyNavbar.min.js"></script>" & @CRLF & _ "</body>" & @CRLF & _ "</html>" Local $aArray = StringRegExp($sString, $sRegex, $STR_REGEXPARRAYGLOBALFULLMATCH) Local $aFullArray[0] For $i = 0 To UBound($aArray) -1 _ArrayConcatenate($aFullArray, $aArray[$i]) Next $aArray = $aFullArray ; 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