Regular Expressions 101

Save & Share

  • Regex Version: ver. 31
  • 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
No Match

/
/
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 = "(?<=^|[\n;](?:[\t ]*(?:\w+ )?)?)import\s*(?<type>type(?=\s+))?(?:[\s"']*(?<imports>[\w\t\n\r "$'*,/{}-]+?)\s+from\s*)?["']\s*(?<specifier>(?:(?<='\s*)[^']*[^\s'](?=\s*'))|(?:(?<="\s*)[^"]*[^\s"](?=\s*")))\s*["'](?:\s+assert\s+(?<assertion>{[\w\t\n\r "':]+?}))?(?=[\s;]*)" Local $sString = "/**" & @CRLF & _ " * @file Interfaces" & @CRLF & _ " * @module mlly/interfaces" & @CRLF & _ " */" & @CRLF & _ "" & @CRLF & _ "export type { default as DynamicImport } from './import-dynamic'" & @CRLF & _ "export type { default as StaticImport } from './import-static'" & @CRLF & _ "export type { default as ResolveOptions } from './options-resolve'" & @CRLF & _ "export type { default as ResolveAliasOptions } from './options-resolve-alias'" & @CRLF & _ "export type { default as Statement } from './statement'" & @CRLF & _ "export type { default as ExportStatement } from './statement-export'" & @CRLF & _ "export type { default as ImportStatement } from './statement-import'" & @CRLF & _ "export type { default as RequireStatement } from './statement-require'" & @CRLF & _ "" & @CRLF & _ "import { CONDITIONS, RESOLVE_EXTENSIONS } from '#src/constants'" & @CRLF & _ "import type { ResolveOptions } from '#src/interfaces'" & @CRLF & _ "import type { SpecifierType } from '#src/types'" & @CRLF & _ "import isBuiltin from '@flex-development/is-builtin'" & @CRLF & _ "import { moduleResolve, type ErrnoException } from 'import-meta-resolve'" & @CRLF & _ "import { pathToFileURL, URL } from 'node:url'" & @CRLF & _ "import upath from 'upath'" & @CRLF & _ "import toBareSpecifier from './to-bare-specifier'" & @CRLF & _ "import toRelativeSpecifier from './to-relative-specifier'" & @CRLF & _ "import 'file:///home/dir/file.ts'" & @CRLF & _ "" & @CRLF & _ "import pkg from './package.json' assert { type:'json' }" & @CRLF & _ "import * as color from 'colorette'" & @CRLF & _ "import consola from 'consola'" & @CRLF & _ "import { defu } from 'defu'" & @CRLF & _ "import type { Format } from 'esbuild'" & @CRLF & _ "import fse from 'fs-extra'" & @CRLF & _ "import * as pathe from 'pathe'" & @CRLF & _ "import { resolve } from 'node:path'" & @CRLF & _ "import url from 'node:url'" & @CRLF & _ "import type { PackageJson } from 'pkg-types'" & @CRLF & _ "import pb from 'pretty-bytes'" & @CRLF & _ "import { EXT_DTS_REGEX, IGNORE_PATTERNS } from './config/constants'" & @CRLF & _ "import loadBuildConfig from './config/load'" & @CRLF & _ "import type { Config, Entry, Result } from './interfaces'" & @CRLF & _ "import type { OutputExtension } from './types'" & @CRLF & _ "import { readPackage, type PackageJson } from "read-pkg"" & @CRLF & _ "import {OutputExtension} from './types'" & @CRLF & _ "import analyzeResults from './utils/analyze-results'" & @CRLF & _ "import esbuilder from './utils/esbuilder'; import write from './utils/write';import write2 from './utils/write'" & @CRLF & _ "// import write from './utils/write'" & @CRLF & _ "import 'side-effect.mjs'" & @CRLF & _ "import type StatementType from '../types/statement-type'" & @CRLF & _ "import type {" & @CRLF & _ " BuildOptions," & @CRLF & _ " BuildResult," & @CRLF & _ " OutputFile," & @CRLF & _ " Plugin," & @CRLF & _ " PluginBuild" & @CRLF & _ "} from './esbuild'" & @CRLF & _ "" & @CRLF & _ "import defaultExport from "module-name";" & @CRLF & _ "import * as name from "module-name";" & @CRLF & _ "import { export1 } from "module-name";" & @CRLF & _ "import { export1 as alias1 } from "module-name";" & @CRLF & _ "import { default as alias } from "module-name";" & @CRLF & _ "import { export1, export2 } from "module-name";" & @CRLF & _ "import { export1, export2 as alias2 } from "module-name";" & @CRLF & _ "import { 'string name' as alias } from "module-name";" & @CRLF & _ "import { "string name" as alias } from "module-name";" & @CRLF & _ "import defaultExport, { export1 } from "module-name";" & @CRLF & _ "import defaultExport, * as name from "module-name";" & @CRLF & _ "import "module-name";" & @CRLF & _ "import 'module-name';" & @CRLF & _ "import './polyfill.mjs'" & @CRLF & _ "import { "h-i" as hi } from './hi.js'" & @CRLF & _ "import { 'j-k' as jk } from "./jk.js"" & @CRLF & _ "" & @CRLF & _ "declare module '__fixtures__/values' {" & @CRLF & _ " import MAX_VALUE from '#fixtures/max-value'" & @CRLF & _ " import MIN_VALUE from '#fixtures/min-value'" & @CRLF & _ "}" & @CRLF & _ "" & @CRLF & _ "const ERR_UNSUPPORTED_DIR_IMPORT: NodeErrorConstructor<" & @CRLF & _ " ErrorConstructor," & @CRLF & _ " [string, string]" & @CRLF & _ "> = createNodeError(" & @CRLF & _ " ErrorCode.ERR_UNSUPPORTED_DIR_IMPORT," & @CRLF & _ " Error," & @CRLF & _ " 'Directory import '%s' is not supported resolving ES modules imported from %s'" & @CRLF & _ ")" & @CRLF & _ "" & @CRLF & _ "const text: string = await resolveModules(output.text, {" & @CRLF & _ " conditions: [format === 'esm' ? 'import' : 'require']," & @CRLF & _ " ext: ext as Ext," & @CRLF & _ " extensions," & @CRLF & _ " parent" & @CRLF & _ "})" & @CRLF & _ "" & @CRLF & _ "/**" & @CRLF & _ " * @example" & @CRLF & _ " * import write from './utils/write'" & @CRLF & _ " * write()" & @CRLF & _ " */" & @CRLF & _ "" & @CRLF & _ "import { 'j-k' as jk } from "./jk.js"" 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