Regular Expressions 101

Save & Share

  • Regex Version: ver. 1
  • 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 single character of: a, b, c or d
    [[ab][cd]]
  • 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
No Match

"
"
g

Test String

Code Generator

Generated Code

package main import ( "regexp" "fmt" ) func main() { var re = regexp.MustCompile(`\w{0,10}((?i)(access.{0,1}key)|(access.{0,1}token)|(access.{0,1}id)|(secret.{0,1}key)|(secret.{0,1}token)|(api.{0,1}key)|(api.{0,1}secret)|(sign.{0,1}in)|(credential[A-Za-z0-9_\-]{0,22})|ak|sk|akid|skid|auth|authentication|certificate|cookie|session|passwd|password|private|token|salt|secretid|accesskeyid|access_key_id|上线|发布|部署|令牌|凭证|口令|密码|密钥|登录|登陆|私钥|秘钥|认证|证书|帐号|账号|账密|配置|鉴权|验证|数据库|用户名|访问码|账号管理)\s*[=:]\s*\"[A-Za-z0-9_\-]{6,33}\" `) var str = `accesskey: "123456pwd" accessKey: "123456pwd" AccessKey: "123456pwd" access key: "123456pwd" access_key: "123456pwd" secretkey: "123456pwd" secretKey: "123456pwd" SecretKey: "123456pwd" secret key: "123456pwd" secret_key: "123456pwd" ak: "123456pwd" sk: "123456pwd" CredentialAzureAccessKey: "123456pwd" CredentialKeyAli: "123456pwd" CredentialKeyKingsoft: "123456pwd" CredentialKeyTencent: "123456pwd" CredentialSecretAli: "123456pwd" CredentialSecretKingsoft: "123456pwd" CredentialSecretTencent: "123456pwd" CredentialUcloudPrivateKey: "123456pwd" CredentialUcloudPublicKey: "123456pwd" CredentialXingyuAccessKey: "123456pwd" CredentialXingyuAccessSecret: "123456pwd" Dockerfile: "123456pwd" AkamaiAccessToken: "123456pwd" AkamaiClientSecret: "123456pwd" AkamaiClientToken: "123456pwd" AwsSecretId: "123456pwd" AwsSecretKey: "123456pwd" AzureSubscriptionId: "123456pwd" CredentialAzureAccessKey: "123456pwd" CredentialKeyAli: "123456pwd" CredentialKeyKingsoft: "123456pwd" CredentialKeyTencent: "123456pwd" CredentialSecretAli: "123456pwd" CredentialSecretKingsoft: "123456pwd" CredentialSecretTencent: "123456pwd" CredentialUcloudPrivateKey: "123456pwd" CredentialUcloudPublicKey: "123456pwd" CredentialXingyuAccessKey: "123456pwd" CredentialXingyuAccessSecret: "123456pwd" 1. Access Key 相关:: "123456pwd" - Access Key: "123456pwd" - AccessKey: "123456pwd" - Access_Key: "123456pwd" - AccessKeyID: "123456pwd" - AccessKeyId: "123456pwd" - Access_Key_ID: "123456pwd" - AK: "123456pwd" - AKID: "123456pwd" 2. Secret Key 相关:: "123456pwd" - Secret Key: "123456pwd" - SecretKey: "123456pwd" - Secret_Key: "123456pwd" - SecretAccessKey: "123456pwd" - Secret_Access_Key: "123456pwd" - SK: "123456pwd" - Secret: "123456pwd" 3. Access Token 相关:: "123456pwd" - Access Token: "123456pwd" - AccessToken: "123456pwd" - Token: "123456pwd" - AuthToken: "123456pwd" - Bearer Token: "123456pwd" - Refresh Token: "123456pwd" 1. 账号相关:: "123456pwd" - Username: "123456pwd" - User: "123456pwd" - Account: "123456pwd" - Login: "123456pwd" - Email: "123456pwd" - UserID: "123456pwd" - 用户名: "123456pwd" - 账户: "123456pwd" 2. 密码相关:: "123456pwd" - Password: "123456pwd" - Pass: "123456pwd" - Pwd: "123456pwd" - 密码: "123456pwd" - 口令: "123456pwd" - 访问码: "123456pwd" 3. 登录相关:: "123456pwd" - Signin: "123456pwd" - Sign in: "123456pwd" - Sign-in: "123456pwd" - 登录: "123456pwd" - 登陆: "123456pwd" - 登入: "123456pwd" 4. 认证相关:: "123456pwd" - Authentication: "123456pwd" - Auth: "123456pwd" - 认证: "123456pwd" - 鉴权: "123456pwd" - 验证: "123456pwd" 5. 凭证相关:: "123456pwd" - Credential: "123456pwd" - Credentials: "123456pwd" - 凭证: "123456pwd" - 证书: "123456pwd" - 令牌: "123456pwd" ` for i, match := range re.FindAllString(str, -1) { fmt.Println(match, "found at index", i) } }

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 Golang, please visit: https://golang.org/pkg/regexp/