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
  • 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

/
/
ig

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 = "(?i)('providers' => \[)([^[\]]*)(\n \],)" Local $sString = "<?php" & @CRLF & _ "" & @CRLF & _ "return [" & @CRLF & _ "" & @CRLF & _ " /*" & @CRLF & _ " |--------------------------------------------------------------------------" & @CRLF & _ " | Application Environment" & @CRLF & _ " |--------------------------------------------------------------------------" & @CRLF & _ " |" & @CRLF & _ " | This value determines the "environment" your application is currently" & @CRLF & _ " | running in. This may determine how you prefer to configure various" & @CRLF & _ " | services your application utilizes. Set this in your ".env" file." & @CRLF & _ " |" & @CRLF & _ " */" & @CRLF & _ "" & @CRLF & _ " 'env' => env('APP_ENV', 'production')," & @CRLF & _ "" & @CRLF & _ " /*" & @CRLF & _ " |--------------------------------------------------------------------------" & @CRLF & _ " | Application Debug Mode" & @CRLF & _ " |--------------------------------------------------------------------------" & @CRLF & _ " |" & @CRLF & _ " | When your application is in debug mode, detailed error messages with" & @CRLF & _ " | stack traces will be shown on every error that occurs within your" & @CRLF & _ " | application. If disabled, a simple generic error page is shown." & @CRLF & _ " |" & @CRLF & _ " */" & @CRLF & _ "" & @CRLF & _ " 'debug' => env('APP_DEBUG', false)," & @CRLF & _ "" & @CRLF & _ " /*" & @CRLF & _ " |--------------------------------------------------------------------------" & @CRLF & _ " | Application URL" & @CRLF & _ " |--------------------------------------------------------------------------" & @CRLF & _ " |" & @CRLF & _ " | This URL is used by the console to properly generate URLs when using" & @CRLF & _ " | the Artisan command line tool. You should set this to the root of" & @CRLF & _ " | your application so that it is used when running Artisan tasks." & @CRLF & _ " |" & @CRLF & _ " */" & @CRLF & _ "" & @CRLF & _ " 'url' => env('API_URL', 'http://localhost')," & @CRLF & _ "" & @CRLF & _ " /*" & @CRLF & _ " |--------------------------------------------------------------------------" & @CRLF & _ " | Application Timezone" & @CRLF & _ " |--------------------------------------------------------------------------" & @CRLF & _ " |" & @CRLF & _ " | Here you may specify the default timezone for your application, which" & @CRLF & _ " | will be used by the PHP date and date-time functions. We have gone" & @CRLF & _ " | ahead and set this to a sensible default for you out of the box." & @CRLF & _ " |" & @CRLF & _ " */" & @CRLF & _ "" & @CRLF & _ " 'timezone' => 'CET'," & @CRLF & _ "" & @CRLF & _ " /*" & @CRLF & _ " |--------------------------------------------------------------------------" & @CRLF & _ " | Application Locale Configuration" & @CRLF & _ " |--------------------------------------------------------------------------" & @CRLF & _ " |" & @CRLF & _ " | The application locale determines the default locale that will be used" & @CRLF & _ " | by the translation service provider. You are free to set this value" & @CRLF & _ " | to any of the locales which will be supported by the application." & @CRLF & _ " |" & @CRLF & _ " */" & @CRLF & _ "" & @CRLF & _ " 'locale' => 'fr'," & @CRLF & _ "" & @CRLF & _ " /*" & @CRLF & _ " |--------------------------------------------------------------------------" & @CRLF & _ " | Application Fallback Locale" & @CRLF & _ " |--------------------------------------------------------------------------" & @CRLF & _ " |" & @CRLF & _ " | The fallback locale determines the locale to use when the current one" & @CRLF & _ " | is not available. You may change the value to correspond to any of" & @CRLF & _ " | the language folders that are provided through your application." & @CRLF & _ " |" & @CRLF & _ " */" & @CRLF & _ "" & @CRLF & _ " 'fallback_locale' => 'en'," & @CRLF & _ "" & @CRLF & _ " /*" & @CRLF & _ " |--------------------------------------------------------------------------" & @CRLF & _ " | Encryption Key" & @CRLF & _ " |--------------------------------------------------------------------------" & @CRLF & _ " |" & @CRLF & _ " | This key is used by the Illuminate encrypter service and should be set" & @CRLF & _ " | to a random, 32 character string, otherwise these encrypted strings" & @CRLF & _ " | will not be safe. Please do this before deploying an application!" & @CRLF & _ " |" & @CRLF & _ " */" & @CRLF & _ "" & @CRLF & _ " 'key' => env('APP_KEY')," & @CRLF & _ "" & @CRLF & _ " 'cipher' => 'AES-256-CBC'," & @CRLF & _ "" & @CRLF & _ " /*" & @CRLF & _ " |--------------------------------------------------------------------------" & @CRLF & _ " | Logging Configuration" & @CRLF & _ " |--------------------------------------------------------------------------" & @CRLF & _ " |" & @CRLF & _ " | Here you may configure the log settings for your application. Out of" & @CRLF & _ " | the box, Laravel uses the Monolog PHP logging library. This gives" & @CRLF & _ " | you a variety of powerful log handlers / formatters to utilize." & @CRLF & _ " |" & @CRLF & _ " | Available Settings: "single", "daily", "syslog", "errorlog"" & @CRLF & _ " |" & @CRLF & _ " */" & @CRLF & _ "" & @CRLF & _ " 'log' => env('APP_LOG', 'single')," & @CRLF & _ "" & @CRLF & _ " /*" & @CRLF & _ " |--------------------------------------------------------------------------" & @CRLF & _ " | Autoloaded Service Providers" & @CRLF & _ " |--------------------------------------------------------------------------" & @CRLF & _ " |" & @CRLF & _ " | The service providers listed here will be automatically loaded on the" & @CRLF & _ " | request to your application. Feel free to add your own services to" & @CRLF & _ " | this array to grant expanded functionality to your applications." & @CRLF & _ " |" & @CRLF & _ " */" & @CRLF & _ "" & @CRLF & _ " 'providers' => [" & @CRLF & _ "" & @CRLF & _ " /*" & @CRLF & _ " * Laravel Framework Service Providers..." & @CRLF & _ " */" & @CRLF & _ " Illuminate\Auth\AuthServiceProvider::class," & @CRLF & _ " Illuminate\Broadcasting\BroadcastServiceProvider::class," & @CRLF & _ " Illuminate\Bus\BusServiceProvider::class," & @CRLF & _ " Illuminate\Cache\CacheServiceProvider::class," & @CRLF & _ " Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class," & @CRLF & _ " Illuminate\Cookie\CookieServiceProvider::class," & @CRLF & _ " Illuminate\Database\DatabaseServiceProvider::class," & @CRLF & _ " Illuminate\Encryption\EncryptionServiceProvider::class," & @CRLF & _ " Illuminate\Filesystem\FilesystemServiceProvider::class," & @CRLF & _ " Illuminate\Foundation\Providers\FoundationServiceProvider::class," & @CRLF & _ " Illuminate\Hashing\HashServiceProvider::class," & @CRLF & _ " Illuminate\Mail\MailServiceProvider::class," & @CRLF & _ " Illuminate\Pagination\PaginationServiceProvider::class," & @CRLF & _ " Illuminate\Pipeline\PipelineServiceProvider::class," & @CRLF & _ " Illuminate\Queue\QueueServiceProvider::class," & @CRLF & _ " Illuminate\Redis\RedisServiceProvider::class," & @CRLF & _ " Illuminate\Auth\Passwords\PasswordResetServiceProvider::class," & @CRLF & _ " Illuminate\Session\SessionServiceProvider::class," & @CRLF & _ " Illuminate\Translation\TranslationServiceProvider::class," & @CRLF & _ " Illuminate\Validation\ValidationServiceProvider::class," & @CRLF & _ " Illuminate\View\ViewServiceProvider::class," & @CRLF & _ "" & @CRLF & _ " /*" & @CRLF & _ " * Application Service Providers..." & @CRLF & _ " */" & @CRLF & _ " App\Providers\AppServiceProvider::class," & @CRLF & _ " App\Providers\AuthServiceProvider::class," & @CRLF & _ " App\Providers\EventServiceProvider::class," & @CRLF & _ " App\Providers\RouteServiceProvider::class," & @CRLF & _ "" & @CRLF & _ " ]," & @CRLF & _ "" & @CRLF & _ " /*" & @CRLF & _ " |--------------------------------------------------------------------------" & @CRLF & _ " | Class Aliases" & @CRLF & _ " |--------------------------------------------------------------------------" & @CRLF & _ " |" & @CRLF & _ " | This array of class aliases will be registered when this application" & @CRLF & _ " | is started. However, feel free to register as many as you wish as" & @CRLF & _ " | the aliases are "lazy" loaded so they don't hinder performance." & @CRLF & _ " |" & @CRLF & _ " */" & @CRLF & _ "" & @CRLF & _ " 'aliases' => [" & @CRLF & _ "" & @CRLF & _ " 'App' => Illuminate\Support\Facades\App::class," & @CRLF & _ " 'Artisan' => Illuminate\Support\Facades\Artisan::class," & @CRLF & _ " 'Auth' => Illuminate\Support\Facades\Auth::class," & @CRLF & _ " 'Blade' => Illuminate\Support\Facades\Blade::class," & @CRLF & _ " 'Cache' => Illuminate\Support\Facades\Cache::class," & @CRLF & _ " 'Config' => Illuminate\Support\Facades\Config::class," & @CRLF & _ " 'Cookie' => Illuminate\Support\Facades\Cookie::class," & @CRLF & _ " 'Crypt' => Illuminate\Support\Facades\Crypt::class," & @CRLF & _ " 'DB' => Illuminate\Support\Facades\DB::class," & @CRLF & _ " 'Eloquent' => Illuminate\Database\Eloquent\Model::class," & @CRLF & _ " 'Event' => Illuminate\Support\Facades\Event::class," & @CRLF & _ " 'File' => Illuminate\Support\Facades\File::class," & @CRLF & _ " 'Gate' => Illuminate\Support\Facades\Gate::class," & @CRLF & _ " 'Hash' => Illuminate\Support\Facades\Hash::class," & @CRLF & _ " 'Lang' => Illuminate\Support\Facades\Lang::class," & @CRLF & _ " 'Log' => Illuminate\Support\Facades\Log::class," & @CRLF & _ " 'Mail' => Illuminate\Support\Facades\Mail::class," & @CRLF & _ " 'Password' => Illuminate\Support\Facades\Password::class," & @CRLF & _ " 'Queue' => Illuminate\Support\Facades\Queue::class," & @CRLF & _ " 'Redirect' => Illuminate\Support\Facades\Redirect::class," & @CRLF & _ " 'Redis' => Illuminate\Support\Facades\Redis::class," & @CRLF & _ " 'Request' => Illuminate\Support\Facades\Request::class," & @CRLF & _ " 'Response' => Illuminate\Support\Facades\Response::class," & @CRLF & _ " 'Route' => Illuminate\Support\Facades\Route::class," & @CRLF & _ " 'Schema' => Illuminate\Support\Facades\Schema::class," & @CRLF & _ " 'Session' => Illuminate\Support\Facades\Session::class," & @CRLF & _ " 'Storage' => Illuminate\Support\Facades\Storage::class," & @CRLF & _ " 'URL' => Illuminate\Support\Facades\URL::class," & @CRLF & _ " 'Validator' => Illuminate\Support\Facades\Validator::class," & @CRLF & _ " 'View' => Illuminate\Support\Facades\View::class," & @CRLF & _ "" & @CRLF & _ " ]," & @CRLF & _ "" & @CRLF & _ "];" & @CRLF & _ "" 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