Regular Expressions 101

Save & Manage Regex

  • Current Version: 1
  • Save & Share
  • Community Library

Flavor

  • PCRE2 (PHP)
  • ECMAScript (JavaScript)
  • Python
  • Golang
  • Java
  • .NET 7.0 (C#)
  • Rust
  • PCRE (Legacy)
  • Regex Flavor Guide

Function

  • Match
  • Substitution
  • List
  • Unit Tests
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]
  • Character class intersection
    [\w&&[^\d]]
  • 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
Processing...

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"(?:\<intent\-filter\>)(\n|\s|\w|\W|\b|\B|.)*?(?:\<\/intent\-filter\>)").unwrap(); let string = "<?xml version=\"1.0\" encoding=\"utf-8\"?> <manifest xmlns:android=\"http://schemas.android.com/apk/res/android\" android:versionCode=\"27\" android:versionName=\"3.3.1\" compileSdkVersion=\"28\" compileSdkVersionCodename=\"9\" package=\"xyz.omnicron.caffeinate\" platformBuildVersionCode=\"27\" platformBuildVersionName=\"3.3.1\"> <uses-sdk android:minSdkVersion=\"24\" android:targetSdkVersion=\"28\"/> <uses-permission android:name=\"android.permission.WAKE_LOCK\"/> <uses-permission android:name=\"android.permission.MODIFY_AUDIO_SETTINGS\"/> <uses-permission android:name=\"android.permission.ACCESS_NOTIFICATION_POLICY\"/> <uses-permission android:name=\"android.permission.FOREGROUND_SERVICE\"/> <uses-permission android:name=\"android.permission.INTERNET\"/> <uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/> <uses-permission android:name=\"com.google.android.finsky.permission.BIND_GET_INSTALL_REFERRER_SERVICE\"/> <uses-permission android:name=\"com.google.android.c2dm.permission.RECEIVE\"/> <permission android:name=\"xyz.omnicron.caffeinate.permission.C2D_MESSAGE\" android:protectionLevel=\"signature\"/> <uses-permission android:name=\"xyz.omnicron.caffeinate.permission.C2D_MESSAGE\"/> <application android:theme=\"@2131755014\" android:label=\"@2131689511\" android:icon=\"@2131623936\" android:name=\"xyz.omnicron.caffeinate.Caffeine\" allowBackup=\"true\" supportsRtl=\"true\" appComponentFactory=\"android.support.v4.app.CoreComponentFactory\"> <activity android:name=\"xyz.omnicron.caffeinate.MainActivity\"> <intent-filter> <action android:name=\"android.intent.action.MAIN\"/> <category android:name=\"android.intent.category.LAUNCHER\"/> </intent-filter> </activity> <receiver android:name=\"xyz.omnicron.caffeinate.ActionReceiver\" android:exported=\"true\"> <intent-filter> <action android:name=\"xyz.omnicron.caffeinate.STOP_ACTION\"/> </intent-filter> </receiver> <service android:label=\"@2131689514\" android:icon=\"@2131230861\" android:name=\"xyz.omnicron.caffeinate.services.CaffeinateTileService\" android:permission=\"android.permission.BIND_QUICK_SETTINGS_TILE\"> <meta-data android:name=\"android.service.quicksettings.ACTIVE_TILE\" android:value=\"false\"/> <intent-filter> <action android:name=\"android.service.quicksettings.action.QS_TILE\"/> </intent-filter> </service> <service android:label=\"@2131689583\" android:icon=\"@2131230858\" android:name=\"xyz.omnicron.caffeinate.services.SoundProfileTileService\" android:permission=\"android.permission.BIND_QUICK_SETTINGS_TILE\"> <meta-data android:name=\"android.service.quicksettings.ACTIVE_TILE\" android:value=\"true\"/> <intent-filter> <action android:name=\"android.service.quicksettings.action.QS_TILE\"/> </intent-filter> </service> <service android:name=\"xyz.omnicron.caffeinate.services.CaffeinationService\" android:exported=\"false\"/> <activity android:label=\"@2131689585\" android:name=\"xyz.omnicron.caffeinate.SettingsActivity\"/> <activity android:label=\"A/B Testing Debug Screen\" android:name=\"xyz.omnicron.caffeinate.ABTestingDebugActivity\"> <intent-filter> <action android:name=\"xyz.omnicron.caffeinate.ABTestingDebugActivity\"/> <category android:name=\"android.intent.category.DEFAULT\"/> </intent-filter> </activity> <activity android:theme=\"@2131755016\" android:label=\"@2131689584\" android:name=\"xyz.omnicron.caffeinate.CreditsActivity\"/> <service android:name=\"com.google.firebase.components.ComponentDiscoveryService\"> <meta-data android:name=\"com.google.firebase.components:com.google.firebase.firestore.FirestoreRegistrar\" android:value=\"com.google.firebase.components.ComponentRegistrar\"/> <meta-data android:name=\"com.google.firebase.components:com.google.firebase.analytics.connector.internal.AnalyticsConnectorRegistrar\" android:value=\"com.google.firebase.components.ComponentRegistrar\"/> <meta-data android:name=\"com.google.firebase.components:com.google.firebase.iid.Registrar\" android:value=\"com.google.firebase.components.ComponentRegistrar\"/> </service> <receiver android:name=\"com.google.android.gms.measurement.AppMeasurementReceiver\" android:enabled=\"true\" android:exported=\"false\"/> <receiver android:name=\"com.google.android.gms.measurement.AppMeasurementInstallReferrerReceiver\" android:permission=\"android.permission.INSTALL_PACKAGES\" android:enabled=\"true\" android:exported=\"true\"> <intent-filter> <action android:name=\"com.android.vending.INSTALL_REFERRER\"/> </intent-filter> </receiver> <service android:name=\"com.google.android.gms.measurement.AppMeasurementService\" android:enabled=\"true\" android:exported=\"false\"/> <service android:name=\"com.google.android.gms.measurement.AppMeasurementJobService\" android:permission=\"android.permission.BIND_JOB_SERVICE\" android:enabled=\"true\" android:exported=\"false\"/> <receiver android:name=\"com.google.firebase.iid.FirebaseInstanceIdReceiver\" android:permission=\"com.google.android.c2dm.permission.SEND\" android:exported=\"true\"> <intent-filter> <action android:name=\"com.google.android.c2dm.intent.RECEIVE\"/> <category android:name=\"xyz.omnicron.caffeinate\"/> </intent-filter> </receiver> <service android:name=\"com.google.firebase.iid.FirebaseInstanceIdService\" android:exported=\"true\"> <intent-filter android:priority=\"-500\"> <action android:name=\"com.google.firebase.INSTANCE_ID_EVENT\"/> </intent-filter> </service> <activity android:theme=\"@16973840\" android:name=\"com.google.android.gms.common.api.GoogleApiActivity\" android:exported=\"false\"/> <provider android:name=\"com.google.firebase.provider.FirebaseInitProvider\" android:exported=\"false\" android:authorities=\"xyz.omnicron.caffeinate.firebaseinitprovider\" android:initOrder=\"100\"/> <meta-data android:name=\"com.google.android.gms.version\" android:value=\"@2131361800\"/> </application> </manifest> "; // 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/