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

/
/
gm

Test String

Substitution

Processing...

Code Generator

Generated Code

#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox Local $sRegex = "(?m)\>(^($|\<\>)|[A-Z a-z0-9\,\.\/\)\(\*\+\:\-]{2,}+)\<\/" Local $sString = "@extends('layouts.index')" & @CRLF & _ "@section('styles')" & @CRLF & _ "<style>" & @CRLF & _ " @media screen and (max-width: 1000px) {" & @CRLF & _ " .btn {" & @CRLF & _ " border-radius: 0.5rem !important;" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ " margin-top: 20px;" & @CRLF & _ " width: 100%;" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " #q {" & @CRLF & _ " border-radius: 0px;" & @CRLF & _ " }" & @CRLF & _ " }" & @CRLF & _ "</style>" & @CRLF & _ "@endsection" & @CRLF & _ "@section('title')" & @CRLF & _ "<title>" & @CRLF & _ " {{ 'Jobs - '.config('app.name')}}" & @CRLF & _ "</title>" & @CRLF & _ "@endsection" & @CRLF & _ "@section('content')" & @CRLF & _ "<div class="container-fluid py-4">" & @CRLF & _ "" & @CRLF & _ " <form action="{{route('jobs.list')}}" method="GET">" & @CRLF & _ " <div class="row g-0">" & @CRLF & _ " <div class="col-lg-3 col-6">" & @CRLF & _ " <input id="q" name="q" class="form-control" value="@if(isset($_GET['q'])){{$_GET['q']}}@endif" type="text" style="border-bottom-right-radius: 0px; border-top-right-radius: 0px" placeholder="Search jobs" autocomplete="off">" & @CRLF & _ " </div>" & @CRLF & _ " <div class="col-lg-2 col-6">" & @CRLF & _ " <select class="form-select" name="category" id="category" style="border-radius: 0px;" aria-label="Default select example">" & @CRLF & _ " <option value="" selected>Categories</option>" & @CRLF & _ " @foreach($categories as $category)" & @CRLF & _ " <option value="{{$category->slug}}">{{$category->name}}</option>" & @CRLF & _ " @endforeach" & @CRLF & _ " </select>" & @CRLF & _ " </div>" & @CRLF & _ " <div class="col-lg-2 col-6">" & @CRLF & _ " <select class="form-select" name="job_type" id="job_type" style="border-radius: 0px;" aria-label="Default select example">" & @CRLF & _ " <option value="" selected>Job Type</option>" & @CRLF & _ " <option value="Part Time">Part Time</option>" & @CRLF & _ " <option value="Full Time">Full Time</option>" & @CRLF & _ " </select>" & @CRLF & _ " </div>" & @CRLF & _ " <div class="col-lg-2 col-6">" & @CRLF & _ " <select class="form-select" name="price_type" id="price_type" style="border-radius: 0px;" aria-label="Default select example">" & @CRLF & _ " <option value="" selected>Price Type</option>" & @CRLF & _ " <option value="Fixed">Fixed</option>" & @CRLF & _ " <option value="Hourly">Hourly</option>" & @CRLF & _ " </select>" & @CRLF & _ " </div>" & @CRLF & _ " <div class="col-lg-3 col-12"><button type="submit" class="btn btn-dark search" style="border-top-left-radius: 0px; border-bottom-left-radius: 0px">Search</button></div>" & @CRLF & _ " </div>" & @CRLF & _ " </form>" & @CRLF & _ "" & @CRLF & _ " <div class="row">" & @CRLF & _ " <div class="col-12">" & @CRLF & _ " <div class="card mb-4">" & @CRLF & _ " <div class="card-header pb-0">" & @CRLF & _ "" & @CRLF & _ " <h6>Jobs</h6>" & @CRLF & _ " @if (session('deleted_job'))" & @CRLF & _ " <span style="color:red">{{session('deleted_job')}}</span>" & @CRLF & _ " @endif" & @CRLF & _ " @if (session('min_length_input'))" & @CRLF & _ " <span style="color:red">{{session('min_length_input')}}</span>" & @CRLF & _ " @endif" & @CRLF & _ " </div>" & @CRLF & _ "" & @CRLF & _ " <div class="card-body px-0 pt-0 pb-2">" & @CRLF & _ " <div class="table-responsive p-0">" & @CRLF & _ " @if (count($jobs)>0)" & @CRLF & _ " <table class="table align-items-center mb-0">" & @CRLF & _ " <thead>" & @CRLF & _ " <tr>" & @CRLF & _ " <th class="text-uppercase text-secondary text-xxs font-weight-bolder opacity-7">Title</th>" & @CRLF & _ " <th class="text-uppercase text-secondary text-xxs font-weight-bolder opacity-7 ps-2">Category/Address</th>" & @CRLF & _ " <th class="text-uppercase text-secondary text-xxs text-center font-weight-bolder opacity-7 ps-2">Price type</th>" & @CRLF & _ " <th class="text-uppercase text-secondary text-xxs text-center font-weight-bolder opacity-7 ps-2">Price</th>" & @CRLF & _ " <th class="text-center text-uppercase text-secondary text-center text-xxs font-weight-bolder opacity-7">Start date</th>" & @CRLF & _ " <th class="text-center text-uppercase text-secondary text-center text-xxs font-weight-bolder opacity-7">End date</th>" & @CRLF & _ " <th class="text-center text-uppercase text-secondary text-center text-xxs font-weight-bolder opacity-7">Options</th>" & @CRLF & _ "" & @CRLF & _ " </tr>" & @CRLF & _ " </thead>" & @CRLF & _ " <tbody>" & @CRLF & _ "" & @CRLF & _ " @foreach($jobs as $job)" & @CRLF & _ "" & @CRLF & _ " <tr>" & @CRLF & _ " <td>" & @CRLF & _ " <a href="{{route('job.show',$job->slug)}}">" & @CRLF & _ " <div class="d-flex px-2 py-1">" & @CRLF & _ " <div>" & @CRLF & _ " <img src="/images/{{$job->user->photo->name}}" class="avatar avatar-sm me-3" alt="user1">" & @CRLF & _ " </div>" & @CRLF & _ " <div class="d-flex flex-column justify-content-center">" & @CRLF & _ " <h6 class="mb-0 text-sm">{{$job->title}}</h6>" & @CRLF & _ " <p class="text-xs text-secondary mb-0">{{$job->user->company->name}}</p>" & @CRLF & _ " </div>" & @CRLF & _ " </div>" & @CRLF & _ " </a>" & @CRLF & _ " </td>" & @CRLF & _ " <td>" & @CRLF & _ " <p class="text-xs font-weight-bold mb-0">{{$job->category->name}}</p>" & @CRLF & _ " <p class="text-xs text-secondary mb-0">{{$job->address}}</p>" & @CRLF & _ " </td>" & @CRLF & _ " <td class="align-middle text-center text-sm">" & @CRLF & _ " <p class="text-xs font-weight-bold mb-0">{{$job->price_type}}</p>" & @CRLF & _ " </td>" & @CRLF & _ " <td class="align-middle text-center text-sm">" & @CRLF & _ " <p class="text-xs font-weight-bold mb-0">{{$job->price}}</p>" & @CRLF & _ " </td>" & @CRLF & _ " <td class="align-middle text-center text-sm">" & @CRLF & _ " <p class="text-xs font-weight-bold mb-0">{{$job->startingDate}}</p>" & @CRLF & _ " </td>" & @CRLF & _ " <td class="align-middle text-center">" & @CRLF & _ " <p class="text-xs font-weight-bold mb-0">{{($job->endingDate) ? $job->endingDate : '/' }}</p>" & @CRLF & _ " </td>" & @CRLF & _ " <td class="align-middle text-center">" & @CRLF & _ " <span class="text-secondary text-xs font-weight-bold">" & @CRLF & _ " <form action="{{route('job.destroy',$job->slug)}}" method="POST" style="display: inline; ">" & @CRLF & _ " @csrf" & @CRLF & _ " @method('DELETE')" & @CRLF & _ " <button type="submit" name="remove_job" style="text-decoration: none; color:red!important; padding: 0; margin:0!important;text-transform: none;" class="btn btn-link">Delete</button>" & @CRLF & _ " </form>" & @CRLF & _ " </span>" & @CRLF & _ " </td>" & @CRLF & _ " </tr>" & @CRLF & _ " @endforeach" & @CRLF & _ "" & @CRLF & _ " </tbody>" & @CRLF & _ "" & @CRLF & _ " </table>" & @CRLF & _ " @else" & @CRLF & _ " <span style="color:red; margin-left: 25px;">No jobs found.</span>" & @CRLF & _ " @endif" & @CRLF & _ " <div class="d-flex justify-content-center mt-3">" & @CRLF & _ " {{$jobs->links()}}" & @CRLF & _ "" & @CRLF & _ " </div>" & @CRLF & _ " </div>" & @CRLF & _ "" & @CRLF & _ " </div>" & @CRLF & _ "" & @CRLF & _ " </div>" & @CRLF & _ " </div>" & @CRLF & _ " </div>" & @CRLF & _ "" & @CRLF & _ " @endsection" & @CRLF & _ " @section('scripts')" & @CRLF & _ " <script>" & @CRLF & _ " const searchBtn = document.querySelector('.search');" & @CRLF & _ " searchBtn.addEventListener('click', function() {" & @CRLF & _ "" & @CRLF & _ " const searchField = document.querySelector('#q');" & @CRLF & _ " const categoriesBtn = document.getElementById('category');" & @CRLF & _ " const categoryValue = categoriesBtn.options[categoriesBtn.selectedIndex].text;" & @CRLF & _ "" & @CRLF & _ " const jobtypeBtn = document.getElementById('job_type');" & @CRLF & _ " const jobtypeValue = jobtypeBtn.options[jobtypeBtn.selectedIndex].text;" & @CRLF & _ "" & @CRLF & _ " const pricetypeBtn = document.getElementById('price_type');" & @CRLF & _ " const pricetypeValue = pricetypeBtn.options[pricetypeBtn.selectedIndex].text;" & @CRLF & _ "" & @CRLF & _ " if (searchField.value == '') {" & @CRLF & _ " searchField.disabled = true;" & @CRLF & _ " }" & @CRLF & _ " if (categoryValue == 'Categories') {" & @CRLF & _ " categoriesBtn.disabled = true;" & @CRLF & _ " }" & @CRLF & _ " if (jobtypeValue == 'Job Type') {" & @CRLF & _ " jobtypeBtn.disabled = true;" & @CRLF & _ " }" & @CRLF & _ " if (pricetypeValue == 'Price Type') {" & @CRLF & _ " pricetypeBtn.disabled = true;" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " });" & @CRLF & _ " </script>" & @CRLF & _ "" & @CRLF & _ " @endsection" Local $sSubst = ">{{__("$1")}}</" Local $sResult = StringRegExpReplace($sString, $sRegex, $sSubst) MsgBox($MB_SYSTEMMODAL, "Result", $sResult)

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