Regular Expressions 101

Save & Share

  • Regex Version: ver. 2
  • 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

const regex = /```[\S\s]*?```/g; // Alternative syntax using RegExp constructor // const regex = new RegExp('```[\\S\\s]*?```', 'g') const str = `## 使用指南 (Usage) **下载使用** \`\`\`js git clone https://github.com/BiYuqi/webpack-seed.git cd webpack-seed npm install \`\`\` **本地开发(dev)** \`\`\`js npm run dev \`\`\` **打包(build)** * 默认情况下,该配置方案假设你的应用是被部署在一个域名的根路径上例如 https://www.my-app.com/ * 如果应用被部署在一个子路径上,你就需要用这个选项指定这个子路径 * 例如,如果你的应用被部署在 https://www.my-app.com/my-app/ * 则设置 webpack的output.publicPath 为 /my-app/ * 本项目由于需要临时部署在git-pages预览 所以改配置临时改为/webpack-seed/ * 普通打包(大部分) npm run build 默认 '/' * 该命令具体请看package.json scripts命令配置 * [配置详情](https://github.com/BiYuqi/webpack-seed/blob/master/webpack.seed.common.js#L13) * [scripts命令配置](https://github.com/BiYuqi/webpack-seed/blob/master/package.json#L8) \`\`\`js // 普通打包(大部分) npm run build publicPath默认 '/' npm run build // 打包时 npm run build:git 该命令会打包的路径会自动带上github项目地址/webpack-seed/ //(当发布环境不是服务器根路径,都可以采用该方案,只需更改路径名称即可,本项目二级路径为webpack-seed) npm run build:git \`\`\` **依赖分析** \`\`\`js // 利用webpack-bundle-analyzer 进行代码构建分析 npm run analyzer \`\`\` **测试** \`\`\`js // karma mocha chai npm run test \`\`\` ## 开发规范 (Standard) 查看[INSTRODUCTION](https://github.com/BiYuqi/webpack-seed/blob/master/INSTRODUCTION.md) ## 接口配置 (Api Setting) 查看[API/README](https://github.com/BiYuqi/webpack-seed/blob/master/src/api/README.md) ## 目录结构 (Source) 查看[INSTRODUCTION](https://github.com/BiYuqi/webpack-seed/blob/master/INSTRODUCTION.md#%E7%9B%AE%E5%BD%95%E7%BB%93%E6%9E%84-source) ## 输出目录 (Output) [查看输出](https://github.com/BiYuqi/webpack-seed/tree/gh-pages) * dist/ * ---html * ---image * ---media * ---css * ---js * ---lib * ---index.html > 注意:如果有音视频等,会被打包在media目录 ## TODO - [x] 添加ejs模板,进行页面(首尾)复用, 页面功能模板渲染 - [x] mini-css-extract-plugin 提取js内引入scss文件失败, 打包后依然在js文件(已解决) - [x] 首页页面模板未完成(单独处理打包) - [x] 添加第三方库以链接的方式引入 - [x] 增加ESLint代码校验 - [x] 增加两个文件夹,一个是fix IE兼容, 一个是引入的公用库,自动加载第三方库到页面,避免手动填写 - [x] 增加网站未登录的模板(无header,footer) - [x] 添加多样化layout模板支持(示例layout/layoutAuth) - [x] 搭建单元测试环境(基于karma mocha chai) - [x] 单独抽离配置文件webpack.seed.common.js - [ ] 待完善测试用例编写 - [ ] 添加doc使用说明以及实现思路解析 ## DOING - [ ] 添加doc使用说明以及实现思路解析 ## LONG TODO(Base on master) - [ ] 搭建国际化版本 - [ ] 建立分支web-system (后台管理系统模板) - [ ] 添加完整网站demo示例 - [ ] 大众网站模板 - [ ] web-mobile(移动端模板) ## 更新日志 (Update log) 查看[CHANGELOG](https://github.com/BiYuqi/webpack-seed/blob/master/CHANGELOG.md) > 本项目目前接口(使用axios只能支持到IE10+), 项目本身支持IE9+ ## 贡献代码 * 先 Fork (https://github.com/BiYuqi/webpack-seed/fork) * 创建分支 (git checkout -b your-idea) * 提交更改 (git commit -am 'Fixed something') * 推送更改 (git push origin your-idea) * 创建一个 Pull Request > [Pull Request使用](http://www.ruanyifeng.com/blog/2017/07/pull_request.html) ## 参考(Thanks) 本脚手架开发中,ejs模板渲染实现这块参考了[webpack-seed](https://github.com/Array-Huang/webpack-seed), 特此备注`; // Reset `lastIndex` if this regex is defined globally // regex.lastIndex = 0; let m; while ((m = regex.exec(str)) !== null) { // This is necessary to avoid infinite loops with zero-width matches if (m.index === regex.lastIndex) { regex.lastIndex++; } // The result can be accessed through the `m`-variable. m.forEach((match, groupIndex) => { console.log(`Found match, group ${groupIndex}: ${match}`); }); }

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 JavaScript, please visit: https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions