Regular Expressions 101

Save & Share

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
  • Match everything enclosed
    (?:...)
  • Capture everything enclosed
    (...)
  • 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"
"
msgui

Test String

Code Generator

Generated Code

// include the latest version of the regex crate in your Cargo.toml extern crate regex; use regex::Regex; fn main() { let regex = Regex::new(r#"(?msui)<time from="(?P<TimeFrom>[\dT:-]*)" to="(?P<TimeTo>[\dT:-]*)" period="\d">.*?(?P<symbol>symbol number="\d").*?\>.*?(?P<percipication>precipitation value="\d").*?\>.*?(?P<windSpeed>windSpeed mps="[\d\.]*").*?\>.*?</time>"#).unwrap(); let string = "<?xml version=\"1.0\" encoding=\"utf-8\"?> <weatherdata> <location> <name>Rykkinn</name> <type>Settlement</type> <country>Norway</country> <timezone id=\"Europe/Oslo\" utcoffsetMinutes=\"120\" /> <location altitude=\"106\" latitude=\"59.9287412518508\" longitude=\"10.4753151421641\" geobase=\"ssr\" geobaseid=\"2234308\" /> </location> <credit> <!--In order to use the free weather data from yr no, you HAVE to display the following text clearly visible on your web page. The text should be a link to the specified URL.--> <!--Please read more about our conditions and guidelines at http://om.yr.no/verdata/ English explanation at http://om.yr.no/verdata/free-weather-data/--> <link text=\"Weather forecast from yr.no, delivered by the Norwegian Meteorological Institute and the NRK\" url=\"http://www.yr.no/place/Norway/Akershus/Bærum/Rykkinn/\" /> </credit> <links> <link id=\"xmlSource\" url=\"http://www.yr.no/place/Norway/Akershus/Bærum/Rykkinn/forecast.xml\" /> <link id=\"xmlSourceHourByHour\" url=\"http://www.yr.no/place/Norway/Akershus/Bærum/Rykkinn/forecast_hour_by_hour.xml\" /> <link id=\"overview\" url=\"http://www.yr.no/place/Norway/Akershus/Bærum/Rykkinn/\" /> <link id=\"hourByHour\" url=\"http://www.yr.no/place/Norway/Akershus/Bærum/Rykkinn/hour_by_hour\" /> <link id=\"longTermForecast\" url=\"http://www.yr.no/place/Norway/Akershus/Bærum/Rykkinn/long\" /> <link id=\"radar\" url=\"http://www.yr.no/place/Norway/Akershus/Bærum/Rykkinn/radar.html\" /> </links> <meta> <lastupdate>2015-09-29T10:33:00</lastupdate> <nextupdate>2015-09-29T18:00:00</nextupdate> </meta> <sun rise=\"2015-09-29T07:17:49\" set=\"2015-09-29T18:57:55\" /> <forecast> <text> <location name=\"Rykkinn\"> <time from=\"2015-09-29\" to=\"2015-09-29\"> <title>Tuesday</title> <body>&lt;strong&gt;Østlandet og Telemark:&lt;/strong&gt; Sørvestlig bris, i ettermiddag forbigående liten kuling på kysten. Etter hvert stort sett pent vær.</body> </time> <time from=\"2015-09-30\" to=\"2015-09-30\"> <title>Wednesday</title> <body>&lt;strong&gt;Østlandet:&lt;/strong&gt; Vestlig eller skiftende bris. Stort sett pent vær, men om natten og først på dagen mulighet for lokal tåke.</body> </time> <time from=\"2015-10-01\" to=\"2015-10-01\"> <title>Thursday</title> <body>&lt;strong&gt;Østafjells:&lt;/strong&gt; Vestlig bris, liten kuling på kysten vest for Lindesnes. Oppholdsvær og perioder med sol.</body> </time> <time from=\"2015-10-02\" to=\"2015-10-02\"> <title>Friday</title> <body>&lt;strong&gt;Østafjells:&lt;/strong&gt; Vestlig bris, periodevis kuling på kysten vest for Lindesnes. Stort sett pent vær. Omtrent uendret temperatur.</body> </time> <time from=\"2015-10-03\" to=\"2015-10-04\"> <title>Saturday and Sunday</title> <body>&lt;strong&gt;Østafjells og fjellet i Sør-Norge:&lt;/strong&gt; Skiftende bris. Lørdag oppholdsvær og perioder med sol. Omtrent uendret temperatur. Søndag spredt regn. Litt lavere temperatur.</body> </time> <time from=\"2015-10-05\" to=\"2015-10-08\"> <title>Monday to Thursday</title> <body>&lt;strong&gt;Sør-Norge:&lt;/strong&gt; Høytrykket flytter seg østover og gir rom for mer ustabilt vær. Overveiende sørlig vind, perioder med kuling på kysten. Etterhvert perioder med nedbør. Litt lavere dagtemperaturer.</body> </time> </location> </text> <tabular> <time from=\"2015-09-29T17:00:00\" to=\"2015-09-29T18:00:00\" period=\"2\"> <!-- Valid from 2015-09-29T17:00:00 to 2015-09-29T18:00:00 --> <symbol number=\"3\" numberEx=\"3\" name=\"Partly cloudy\" var=\"03d\" /> <precipitation value=\"0\" /> <!-- Valid at 2015-09-29T17:00:00 --> <windDirection deg=\"140.3\" code=\"SE\" name=\"Southeast\" /> <windSpeed mps=\"1.5\" name=\"Light air\" /> <temperature unit=\"celsius\" value=\"15\" /> <pressure unit=\"hPa\" value=\"1035.7\" /> </time> <time from=\"2015-09-29T18:00:00\" to=\"2015-09-30T00:00:00\" period=\"3\"> <!-- Valid from 2015-09-29T18:00:00 to 2015-09-30T00:00:00 --> <symbol number=\"3\" numberEx=\"3\" name=\"Partly cloudy\" var=\"mf/03n.53\" /> <precipitation value=\"0\" /> <!-- Valid at 2015-09-29T18:00:00 --> <windDirection deg=\"132.5\" code=\"SE\" name=\"Southeast\" /> <windSpeed mps=\"1.4\" name=\"Light air\" /> <temperature unit=\"celsius\" value=\"14\" /> <pressure unit=\"hPa\" value=\"1035.3\" /> </time> <time from=\"2015-09-30T00:00:00\" to=\"2015-09-30T06:00:00\" period=\"0\"> <!-- Valid from 2015-09-30T00:00:00 to 2015-09-30T06:00:00 --> <symbol number=\"3\" numberEx=\"3\" name=\"Partly cloudy\" var=\"mf/03n.56\" /> <precipitation value=\"0\" /> <!-- Valid at 2015-09-30T00:00:00 --> <windDirection deg=\"358.4\" code=\"N\" name=\"North\" /> <windSpeed mps=\"2.0\" name=\"Light breeze\" /> <temperature unit=\"celsius\" value=\"6\" /> <pressure unit=\"hPa\" value=\"1035.1\" /> </time> <time from=\"2015-09-30T06:00:00\" to=\"2015-09-30T12:00:00\" period=\"1\"> <!-- Valid from 2015-09-30T06:00:00 to 2015-09-30T12:00:00 --> <symbol number=\"2\" numberEx=\"2\" name=\"Fair\" var=\"02d\" /> <precipitation value=\"0\" /> <!-- Valid at 2015-09-30T06:00:00 --> <windDirection deg=\"68.7\" code=\"ENE\" name=\"East-northeast\" /> <windSpeed mps=\"0.6\" name=\"Light air\" /> <temperature unit=\"celsius\" value=\"4\" /> <pressure unit=\"hPa\" value=\"1033.8\" /> </time> <time from=\"2015-09-30T12:00:00\" to=\"2015-09-30T18:00:00\" period=\"2\"> <!-- Valid from 2015-09-30T12:00:00 to 2015-09-30T18:00:00 --> <symbol number=\"2\" numberEx=\"2\" name=\"Fair\" var=\"02d\" /> <precipitation value=\"0\" /> <!-- Valid at 2015-09-30T12:00:00 --> <windDirection deg=\"143.9\" code=\"SE\" name=\"Southeast\" /> <windSpeed mps=\"1.1\" name=\"Light air\" /> <temperature unit=\"celsius\" value=\"13\" /> <pressure unit=\"hPa\" value=\"1034.1\" /> </time> <time from=\"2015-09-30T18:00:00\" to=\"2015-10-01T00:00:00\" period=\"3\"> <!-- Valid from 2015-09-30T18:00:00 to 2015-10-01T00:00:00 --> <symbol number=\"3\" numberEx=\"3\" name=\"Partly cloudy\" var=\"mf/03n.56\" /> <precipitation value=\"0\" /> <!-- Valid at 2015-09-30T18:00:00 --> <windDirection deg=\"129.3\" code=\"SE\" name=\"Southeast\" /> <windSpeed mps=\"0.6\" name=\"Light air\" /> <temperature unit=\"celsius\" value=\"15\" /> <pressure unit=\"hPa\" value=\"1030.6\" /> </time> <time from=\"2015-10-01T00:00:00\" to=\"2015-10-01T06:00:00\" period=\"0\"> <!-- Valid from 2015-10-01T00:00:00 to 2015-10-01T06:00:00 --> <symbol number=\"3\" numberEx=\"3\" name=\"Partly cloudy\" var=\"mf/03n.60\" /> <precipitation value=\"0\" /> <!-- Valid at 2015-10-01T00:00:00 --> <windDirection deg=\"338.6\" code=\"NNW\" name=\"North-northwest\" /> <windSpeed mps=\"1.6\" name=\"Light breeze\" /> <temperature unit=\"celsius\" value=\"7\" /> <pressure unit=\"hPa\" value=\"1028.4\" /> </time> <time from=\"2015-10-01T06:00:00\" to=\"2015-10-01T12:00:00\" period=\"1\"> <!-- Valid from 2015-10-01T06:00:00 to 2015-10-01T12:00:00 --> <symbol number=\"3\" numberEx=\"3\" name=\"Partly cloudy\" var=\"03d\" /> <precipitation value=\"0\" /> <!-- Valid at 2015-10-01T06:00:00 --> <windDirection deg=\"324.0\" code=\"NW\" name=\"Northwest\" /> <windSpeed mps=\"2.5\" name=\"Light breeze\" /> <temperature unit=\"celsius\" value=\"6\" /> <pressure unit=\"hPa\" value=\"1025.8\" /> </time> <time from=\"2015-10-01T12:00:00\" to=\"2015-10-01T18:00:00\" period=\"2\"> <!-- Valid from 2015-10-01T12:00:00 to 2015-10-01T18:00:00 --> <symbol number=\"3\" numberEx=\"3\" name=\"Partly cloudy\" var=\"03d\" /> <precipitation value=\"0\" /> <!-- Valid at 2015-10-01T12:00:00 --> <windDirection deg=\"142.8\" code=\"SE\" name=\"Southeast\" /> <windSpeed mps=\"1.3\" name=\"Light air\" /> <temperature unit=\"celsius\" value=\"13\" /> <pressure unit=\"hPa\" value=\"1025.9\" /> </time> <time from=\"2015-10-01T18:00:00\" to=\"2015-10-02T00:00:00\" period=\"3\"> <!-- Valid from 2015-10-01T18:00:00 to 2015-10-02T00:00:00 --> <symbol number=\"2\" numberEx=\"2\" name=\"Fair\" var=\"mf/02n.60\" /> <precipitation value=\"0\" /> <!-- Valid at 2015-10-01T18:00:00 --> <windDirection deg=\"270.6\" code=\"W\" name=\"West\" /> <windSpeed mps=\"1.0\" name=\"Light air\" /> <temperature unit=\"celsius\" value=\"16\" /> <pressure unit=\"hPa\" value=\"1023.2\" /> </time> <time from=\"2015-10-02T02:00:00\" to=\"2015-10-02T08:00:00\" period=\"0\"> <!-- Valid from 2015-10-02T02:00:00 to 2015-10-02T08:00:00 --> <symbol number=\"4\" numberEx=\"4\" name=\"Cloudy\" var=\"04\" /> <precipitation value=\"0\" /> <!-- Valid at 2015-10-02T02:00:00 --> <windDirection deg=\"143.5\" code=\"SE\" name=\"Southeast\" /> <windSpeed mps=\"0.4\" name=\"Light air\" /> <temperature unit=\"celsius\" value=\"7\" /> <pressure unit=\"hPa\" value=\"1020.1\" /> </time> <time from=\"2015-10-02T08:00:00\" to=\"2015-10-02T14:00:00\" period=\"1\"> <!-- Valid from 2015-10-02T08:00:00 to 2015-10-02T14:00:00 --> <symbol number=\"3\" numberEx=\"3\" name=\"Partly cloudy\" var=\"03d\" /> <precipitation value=\"0\" /> <!-- Valid at 2015-10-02T08:00:00 --> <windDirection deg=\"288.8\" code=\"WNW\" name=\"West-northwest\" /> <windSpeed mps=\"1.7\" name=\"Light breeze\" /> <temperature unit=\"celsius\" value=\"9\" /> <pressure unit=\"hPa\" value=\"1018.2\" /> </time> <time from=\"2015-10-02T14:00:00\" to=\"2015-10-02T20:00:00\" period=\"2\"> <!-- Valid from 2015-10-02T14:00:00 to 2015-10-02T20:00:00 --> <symbol number=\"1\" numberEx=\"1\" name=\"Clear sky\" var=\"01d\" /> <precipitation value=\"0\" /> <!-- Valid at 2015-10-02T14:00:00 --> <windDirection deg=\"234.6\" code=\"SW\" name=\"Southwest\" /> <windSpeed mps=\"1.6\" name=\"Light breeze\" /> <temperature unit=\"celsius\" value=\"16\" /> <pressure unit=\"hPa\" value=\"1018.2\" /> </time> <time from=\"2015-10-02T20:00:00\" to=\"2015-10-03T02:00:00\" period=\"3\"> <!-- Valid from 2015-10-02T20:00:00 to 2015-10-03T02:00:00 --> <symbol number=\"1\" numberEx=\"1\" name=\"Clear sky\" var=\"mf/01n.63\" /> <precipitation value=\"0\" /> <!-- Valid at 2015-10-02T20:00:00 --> <windDirection deg=\"231.8\" code=\"SW\" name=\"Southwest\" /> <windSpeed mps=\"1.7\" name=\"Light breeze\" /> <temperature unit=\"celsius\" value=\"13\" /> <pressure unit=\"hPa\" value=\"1017.4\" /> </time> <time from=\"2015-10-03T02:00:00\" to=\"2015-10-03T08:00:00\" period=\"0\"> <!-- Valid from 2015-10-03T02:00:00 to 2015-10-03T08:00:00 --> <symbol number=\"3\" numberEx=\"3\" name=\"Partly cloudy\" var=\"mf/03n.66\" /> <precipitation value=\"0\" /> <!-- Valid at 2015-10-03T02:00:00 --> <windDirection deg=\"336.2\" code=\"NNW\" name=\"North-northwest\" /> <windSpeed mps=\"1.6\" name=\"Light breeze\" /> <temperature unit=\"celsius\" value=\"10\" /> <pressure unit=\"hPa\" value=\"1018.5\" /> </time> <time from=\"2015-10-03T08:00:00\" to=\"2015-10-03T14:00:00\" period=\"1\"> <!-- Valid from 2015-10-03T08:00:00 to 2015-10-03T14:00:00 --> <symbol number=\"3\" numberEx=\"3\" name=\"Partly cloudy\" var=\"03d\" /> <precipitation value=\"0\" /> <!-- Valid at 2015-10-03T08:00:00 --> <windDirection deg=\"332.3\" code=\"NNW\" name=\"North-northwest\" /> <windSpeed mps=\"1.5\" name=\"Light air\" /> <temperature unit=\"celsius\" value=\"8\" /> <pressure unit=\"hPa\" value=\"1019.1\" /> </time> <time from=\"2015-10-03T14:00:00\" to=\"2015-10-03T20:00:00\" period=\"2\"> <!-- Valid from 2015-10-03T14:00:00 to 2015-10-03T20:00:00 --> <symbol number=\"3\" numberEx=\"3\" name=\"Partly cloudy\" var=\"03d\" /> <precipitation value=\"0\" /> <!-- Valid at 2015-10-03T14:00:00 --> <windDirection deg=\"26.6\" code=\"NNE\" name=\"North-northeast\" /> <windSpeed mps=\"1.2\" name=\"Light air\" /> <temperature unit=\"celsius\" value=\"13\" /> <pressure unit=\"hPa\" value=\"1019.9\" /> </time> <time from=\"2015-10-03T20:00:00\" to=\"2015-10-04T02:00:00\" period=\"3\"> <!-- Valid from 2015-10-03T20:00:00 to 2015-10-04T02:00:00 --> <symbol number=\"4\" numberEx=\"4\" name=\"Cloudy\" var=\"04\" /> <precipitation value=\"0\" /> <!-- Valid at 2015-10-03T20:00:00 --> <windDirection deg=\"153.9\" code=\"SSE\" name=\"South-southeast\" /> <windSpeed mps=\"1.5\" name=\"Light air\" /> <temperature unit=\"celsius\" value=\"11\" /> <pressure unit=\"hPa\" value=\"1019.4\" /> </time> <time from=\"2015-10-04T02:00:00\" to=\"2015-10-04T08:00:00\" period=\"0\"> <!-- Valid from 2015-10-04T02:00:00 to 2015-10-04T08:00:00 --> <symbol number=\"4\" numberEx=\"4\" name=\"Cloudy\" var=\"04\" /> <precipitation value=\"0\" /> <!-- Valid at 2015-10-04T02:00:00 --> <windDirection deg=\"115.6\" code=\"ESE\" name=\"East-southeast\" /> <windSpeed mps=\"1.5\" name=\"Light air\" /> <temperature unit=\"celsius\" value=\"10\" /> <pressure unit=\"hPa\" value=\"1019.1\" /> </time> <time from=\"2015-10-04T08:00:00\" to=\"2015-10-04T14:00:00\" period=\"1\"> <!-- Valid from 2015-10-04T08:00:00 to 2015-10-04T14:00:00 --> <symbol number=\"4\" numberEx=\"4\" name=\"Cloudy\" var=\"04\" /> <precipitation value=\"0\" /> <!-- Valid at 2015-10-04T08:00:00 --> <windDirection deg=\"163.6\" code=\"SSE\" name=\"South-southeast\" /> <windSpeed mps=\"1.2\" name=\"Light air\" /> <temperature unit=\"celsius\" value=\"10\" /> <pressure unit=\"hPa\" value=\"1017.7\" /> </time> <time from=\"2015-10-04T14:00:00\" to=\"2015-10-04T20:00:00\" period=\"2\"> <!-- Valid from 2015-10-04T14:00:00 to 2015-10-04T20:00:00 --> <symbol number=\"4\" numberEx=\"4\" name=\"Cloudy\" var=\"04\" /> <precipitation value=\"0\" /> <!-- Valid at 2015-10-04T14:00:00 --> <windDirection deg=\"163.7\" code=\"SSE\" name=\"South-southeast\" /> <windSpeed mps=\"1.1\" name=\"Light air\" /> <temperature unit=\"celsius\" value=\"11\" /> <pressure unit=\"hPa\" value=\"1017.7\" /> </time> <time from=\"2015-10-04T20:00:00\" to=\"2015-10-05T02:00:00\" period=\"3\"> <!-- Valid from 2015-10-04T20:00:00 to 2015-10-05T02:00:00 --> <symbol number=\"4\" numberEx=\"4\" name=\"Cloudy\" var=\"04\" /> <precipitation value=\"0\" /> <!-- Valid at 2015-10-04T20:00:00 --> <windDirection deg=\"351.4\" code=\"N\" name=\"North\" /> <windSpeed mps=\"1.2\" name=\"Light air\" /> <temperature unit=\"celsius\" value=\"11\" /> <pressure unit=\"hPa\" value=\"1016.5\" /> </time> <time from=\"2015-10-05T02:00:00\" to=\"2015-10-05T08:00:00\" period=\"0\"> <!-- Valid from 2015-10-05T02:00:00 to 2015-10-05T08:00:00 --> <symbol number=\"4\" numberEx=\"4\" name=\"Cloudy\" var=\"04\" /> <precipitation value=\"0\" /> <!-- Valid at 2015-10-05T02:00:00 --> <windDirection deg=\"174.1\" code=\"S\" name=\"South\" /> <windSpeed mps=\"1.2\" name=\"Light air\" /> <temperature unit=\"celsius\" value=\"10\" /> <pressure unit=\"hPa\" value=\"1016.0\" /> </time> <time from=\"2015-10-05T08:00:00\" to=\"2015-10-05T14:00:00\" period=\"1\"> <!-- Valid from 2015-10-05T08:00:00 to 2015-10-05T14:00:00 --> <symbol number=\"4\" numberEx=\"4\" name=\"Cloudy\" var=\"04\" /> <precipitation value=\"0\" /> <!-- Valid at 2015-10-05T08:00:00 --> <windDirection deg=\"225.4\" code=\"SW\" name=\"Southwest\" /> <windSpeed mps=\"1.2\" name=\"Light air\" /> <temperature unit=\"celsius\" value=\"10\" /> <pressure unit=\"hPa\" value=\"1015.1\" /> </time> <time from=\"2015-10-05T14:00:00\" to=\"2015-10-05T20:00:00\" period=\"2\"> <!-- Valid from 2015-10-05T14:00:00 to 2015-10-05T20:00:00 --> <symbol number=\"4\" numberEx=\"4\" name=\"Cloudy\" var=\"04\" /> <precipitation value=\"0\" /> <!-- Valid at 2015-10-05T14:00:00 --> <windDirection deg=\"66.5\" code=\"ENE\" name=\"East-northeast\" /> <windSpeed mps=\"1.8\" name=\"Light breeze\" /> <temperature unit=\"celsius\" value=\"11\" /> <pressure unit=\"hPa\" value=\"1015.2\" /> </time> <time from=\"2015-10-05T20:00:00\" to=\"2015-10-06T02:00:00\" period=\"3\"> <!-- Valid from 2015-10-05T20:00:00 to 2015-10-06T02:00:00 --> <symbol number=\"4\" numberEx=\"4\" name=\"Cloudy\" var=\"04\" /> <precipitation value=\"0\" /> <!-- Valid at 2015-10-05T20:00:00 --> <windDirection deg=\"124.9\" code=\"SE\" name=\"Southeast\" /> <windSpeed mps=\"1.4\" name=\"Light air\" /> <temperature unit=\"celsius\" value=\"10\" /> <pressure unit=\"hPa\" value=\"1014.4\" /> </time> <time from=\"2015-10-06T02:00:00\" to=\"2015-10-06T08:00:00\" period=\"0\"> <!-- Valid from 2015-10-06T02:00:00 to 2015-10-06T08:00:00 --> <symbol number=\"9\" numberEx=\"9\" name=\"Rain\" var=\"09\" /> <precipitation value=\"2.4\" /> <!-- Valid at 2015-10-06T02:00:00 --> <windDirection deg=\"61.0\" code=\"ENE\" name=\"East-northeast\" /> <windSpeed mps=\"2.3\" name=\"Light breeze\" /> <temperature unit=\"celsius\" value=\"11\" /> <pressure unit=\"hPa\" value=\"1010.5\" /> </time> <time from=\"2015-10-06T08:00:00\" to=\"2015-10-06T14:00:00\" period=\"1\"> <!-- Valid from 2015-10-06T08:00:00 to 2015-10-06T14:00:00 --> <symbol number=\"9\" numberEx=\"9\" name=\"Rain\" var=\"09\" /> <precipitation value=\"2.8\" /> <!-- Valid at 2015-10-06T08:00:00 --> <windDirection deg=\"77.9\" code=\"ENE\" name=\"East-northeast\" /> <windSpeed mps=\"2.4\" name=\"Light breeze\" /> <temperature unit=\"celsius\" value=\"11\" /> <pressure unit=\"hPa\" value=\"1004.4\" /> </time> <time from=\"2015-10-06T14:00:00\" to=\"2015-10-06T20:00:00\" period=\"2\"> <!-- Valid from 2015-10-06T14:00:00 to 2015-10-06T20:00:00 --> <symbol number=\"4\" numberEx=\"4\" name=\"Cloudy\" var=\"04\" /> <precipitation value=\"0\" /> <!-- Valid at 2015-10-06T14:00:00 --> <windDirection deg=\"103.5\" code=\"ESE\" name=\"East-southeast\" /> <windSpeed mps=\"2.6\" name=\"Light breeze\" /> <temperature unit=\"celsius\" value=\"12\" /> <pressure unit=\"hPa\" value=\"1014.0\" /> </time> <time from=\"2015-10-06T20:00:00\" to=\"2015-10-07T02:00:00\" period=\"3\"> <!-- Valid from 2015-10-06T20:00:00 to 2015-10-07T02:00:00 --> <symbol number=\"9\" numberEx=\"9\" name=\"Rain\" var=\"09\" /> <precipitation value=\"2.4\" /> <!-- Valid at 2015-10-06T20:00:00 --> <windDirection deg=\"169.5\" code=\"S\" name=\"South\" /> <windSpeed mps=\"3.5\" name=\"Gentle breeze\" /> <temperature unit=\"celsius\" value=\"12\" /> <pressure unit=\"hPa\" value=\"1009.2\" /> </time> <time from=\"2015-10-07T02:00:00\" to=\"2015-10-07T08:00:00\" period=\"0\"> <!-- Valid from 2015-10-07T02:00:00 to 2015-10-07T08:00:00 --> <symbol number=\"4\" numberEx=\"4\" name=\"Cloudy\" var=\"04\" /> <precipitation value=\"0\" /> <!-- Valid at 2015-10-07T02:00:00 --> <windDirection deg=\"87.2\" code=\"E\" name=\"East\" /> <windSpeed mps=\"1.8\" name=\"Light breeze\" /> <temperature unit=\"celsius\" value=\"11\" /> <pressure unit=\"hPa\" value=\"1015.2\" /> </time> <time from=\"2015-10-07T08:00:00\" to=\"2015-10-07T14:00:00\" period=\"1\"> <!-- Valid from 2015-10-07T08:00:00 to 2015-10-07T14:00:00 --> <symbol number=\"4\" numberEx=\"4\" name=\"Cloudy\" var=\"04\" /> <precipitation value=\"0\" /> <!-- Valid at 2015-10-07T08:00:00 --> <windDirection deg=\"85.0\" code=\"E\" name=\"East\" /> <windSpeed mps=\"1.7\" name=\"Light breeze\" /> <temperature unit=\"celsius\" value=\"10\" /> <pressure unit=\"hPa\" value=\"1014.6\" /> </time> <time from=\"2015-10-07T14:00:00\" to=\"2015-10-07T20:00:00\" period=\"2\"> <!-- Valid from 2015-10-07T14:00:00 to 2015-10-07T20:00:00 --> <symbol number=\"4\" numberEx=\"4\" name=\"Cloudy\" var=\"04\" /> <precipitation value=\"0\" /> <!-- Valid at 2015-10-07T14:00:00 --> <windDirection deg=\"302.4\" code=\"WNW\" name=\"West-northwest\" /> <windSpeed mps=\"2.3\" name=\"Light breeze\" /> <temperature unit=\"celsius\" value=\"12\" /> <pressure unit=\"hPa\" value=\"1016.6\" /> </time> <time from=\"2015-10-07T20:00:00\" to=\"2015-10-08T02:00:00\" period=\"3\"> <!-- Valid from 2015-10-07T20:00:00 to 2015-10-08T02:00:00 --> <symbol number=\"9\" numberEx=\"9\" name=\"Rain\" var=\"09\" /> <precipitation value=\"2.1\" /> <!-- Valid at 2015-10-07T20:00:00 --> <windDirection deg=\"111.2\" code=\"ESE\" name=\"East-southeast\" /> <windSpeed mps=\"3.0\" name=\"Light breeze\" /> <temperature unit=\"celsius\" value=\"12\" /> <pressure unit=\"hPa\" value=\"1009.5\" /> </time> <time from=\"2015-10-08T02:00:00\" to=\"2015-10-08T08:00:00\" period=\"0\"> <!-- Valid from 2015-10-08T02:00:00 to 2015-10-08T08:00:00 --> <symbol number=\"4\" numberEx=\"4\" name=\"Cloudy\" var=\"04\" /> <precipitation value=\"0\" /> <!-- Valid at 2015-10-08T02:00:00 --> <windDirection deg=\"283.1\" code=\"WNW\" name=\"West-northwest\" /> <windSpeed mps=\"1.7\" name=\"Light breeze\" /> <temperature unit=\"celsius\" value=\"11\" /> <pressure unit=\"hPa\" value=\"1012.4\" /> </time> <time from=\"2015-10-08T08:00:00\" to=\"2015-10-08T14:00:00\" period=\"1\"> <!-- Valid from 2015-10-08T08:00:00 to 2015-10-08T14:00:00 --> <symbol number=\"4\" numberEx=\"4\" name=\"Cloudy\" var=\"04\" /> <precipitation value=\"0\" /> <!-- Valid at 2015-10-08T08:00:00 --> <windDirection deg=\"4.6\" code=\"N\" name=\"North\" /> <windSpeed mps=\"1.8\" name=\"Light breeze\" /> <temperature unit=\"celsius\" value=\"11\" /> <pressure unit=\"hPa\" value=\"1014.3\" /> </time> <time from=\"2015-10-08T14:00:00\" to=\"2015-10-08T20:00:00\" period=\"2\"> <!-- Valid from 2015-10-08T14:00:00 to 2015-10-08T20:00:00 --> <symbol number=\"4\" numberEx=\"4\" name=\"Cloudy\" var=\"04\" /> <precipitation value=\"0\" /> <!-- Valid at 2015-10-08T14:00:00 --> <windDirection deg=\"150.2\" code=\"SSE\" name=\"South-southeast\" /> <windSpeed mps=\"2.3\" name=\"Light breeze\" /> <temperature unit=\"celsius\" value=\"12\" /> <pressure unit=\"hPa\" value=\"1017.7\" /> </time> </tabular> </forecast> <observations> <weatherstation stno=\"19710\" sttype=\"eklima\" name=\"Asker (Sem)\" distance=\"8384\" lat=\"59.85620\" lon=\"10.43450\" source=\"Meteorologisk Institutt\"> <temperature unit=\"celsius\" value=\"16.2\" time=\"2015-09-29T14:00:00Z\" /> </weatherstation> <weatherstation stno=\"18815\" sttype=\"eklima\" name=\"Bygdøy\" distance=\"11865\" lat=\"59.90500\" lon=\"10.68280\" source=\"Meteorologisk Institutt\"> <temperature unit=\"celsius\" value=\"16.7\" time=\"2015-09-29T14:00:00Z\" /> </weatherstation> <weatherstation stno=\"18950\" sttype=\"eklima\" name=\"Tryvannshøgda\" distance=\"12467\" lat=\"59.98470\" lon=\"10.66930\" source=\"Meteorologisk Institutt\"> <temperature unit=\"celsius\" value=\"12.5\" time=\"2015-09-29T14:00:00Z\" /> <windDirection deg=\"186.0\" code=\"S\" name=\"South\" time=\"2015-09-29T14:00:00Z\" /> <windSpeed mps=\"4.0\" name=\"Gentle breeze\" time=\"2015-09-29T14:00:00Z\" /> </weatherstation> </observations> </weatherdata>"; // result will be an iterator over tuples containing the start and end indices for each match in the string let result = regex.captures_iter(string); for mat in result { println!("{:?}", mat); } }

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 Rust, please visit: https://docs.rs/regex/latest/regex/