regex cheat sheet
regex pattern visualizer : regex101: build, test, and debug regex https://regex101.com/
regex
regex character
| character | meaning |
|---|---|
| \d | digital characters |
| \D | not digital characters |
| \w | Matches any alphanumeric character from the basic Latin alphabet, including the underscore. Equivalent to [A-Za-z0-9_]. |
| \W | Matches any character that is not a word character from the basic Latin alphabet. Equivalent to [^A-Za-z0-9_]. |
| \s | Matches a single white space character, including space, tab, form feed, line feed, and other Unicode spaces. Equivalent to [\f\n\r\t\v\u0020\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]. For example, /\s\w*/ matches " bar" in "foo bar". |
| \b | word boundary. "\baa\b.*" matches "aa bb", dose not match "aabb". |
look ahead and look behind
| Lookaround | Name | What it Does |
|---|---|---|
| (?=foo) | Lookahead | Asserts that what immediately follows the current position in the string is foo |
| (?<=foo) | Lookbehind | Asserts that what immediately precedes the current position in the string is foo |
| (?!foo) | Negative Lookahead | Asserts that what immediately follows the current position in the string is not foo |
| (?<!foo) | Negative Lookbehind | Asserts that what immediately precedes the current position in the string is not foo |
lazy vs greedy
| type | pattern | description |
|---|---|---|
| greedy | .* | matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy) |
| lazy | .*? | matches the previous token between zero and unlimited times, as few times as possible, expanding as needed (lazy) |
ref
Lookahead and Lookbehind Tutorial—Tips &Tricks
https://www.rexegg.com/regex-lookarounds.html
Regex Tutorial - Lookahead and Lookbehind Zero-Length Assertions
https://www.regular-expressions.info/lookaround.html
Regular expressions - JavaScript | MDN
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
Character classes - JavaScript | MDN
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions/Character_Classes
regex cheat sheet的更多相关文章
- XSS Filter Evasion Cheat Sheet 中文版
前言 译者注: 翻译本文的最初原因是当我自己看到这篇文章后,觉得它是非常有价值.但是这么著名的一个备忘录却一直没有人把它翻译成中文版.很多人仅仅是简单的把文中的 各种代码复制下来,然后看起来很刁的发在 ...
- [转]Blue Prism VBO Cheat Sheet
本文转自:https://www.cheatography.com/ethanium/cheat-sheets/blue-prism-vbo/ Blue Prism MAPIEx Configure ...
- Tools - 速查表与备忘单(Cheat Sheet)
Cheat Sheets Rico's cheatsheets Cheat-Sheets.org Python Python Cheat sheet Python Programming Cheat ...
- 转:PostgreSQL Cheat Sheet
PostgreSQL Cheat Sheet CREATE DATABASE CREATE DATABASE dbName; CREATE TABLE (with auto numbering int ...
- Git Cheat Sheet
Merge Undo git merge with conflicts $ git merge --abort Archive $ git archive --format zip --output ...
- CSS3 Animation Cheat Sheet:实用的 CSS3 动画库
CSS3 Animation Cheat Sheet 是一组预设的动画库,为您的 Web 项目添加各种很炫的动画.所有你需要做的是添加样式表到你的网站,为你想要添加动画效果的元素应用预制的 CSS 类 ...
- XSS (Cross Site Scripting) Prevention Cheat Sheet(XSS防护检查单)
本文是 XSS防御检查单的翻译版本 https://www.owasp.org/index.php/XSS_%28Cross_Site_Scripting%29_Prevention_Cheat_Sh ...
- IOS Application Security Testing Cheat Sheet
IOS Application Security Testing Cheat Sheet [hide] 1 DRAFT CHEAT SHEET - WORK IN PROGRESS 2 Int ...
- HTML5 Cheat sheet PNG帮助手册(标签、事件、兼容)
HTML5 Cheat sheet PNG帮助手册(标签.事件.兼容) 1.HTML5标签 2.HTML5事件 3.HTML5兼容 最新HTML5手册资料请参考:http://www.inmotion ...
- [转]Swift Cheat Sheet
原文:http://kpbp.github.io/swiftcheatsheet/ A quick cheat sheet and reference guide for Apple's Swift ...
随机推荐
- quasar打包时:Module not found: Can't resolve imported dependency "dayjs/plugin/customParseFormat"
运行quasar build -m electron 后,报错如下: 看了这篇webpack 编译 element-plus 报错后,找到了报错的根源所在 于是,在quasar官方文档找到了针对web ...
- 自己从零写操作系统GrapeOS系列教程——4.GrapeOS开发环境介绍
1. 开发环境简介 为了减少开发过程中不必要的麻烦,希望大家的开发环境尽量与我的保持一致. 我的开发环境如下: Windows10电脑一台 Visual Studio Code(最好是最新版) Vir ...
- vue api封装 request.js
import axios from 'axios' import { Message, MessageBox } from 'element-ui' import store from '../sto ...
- 【译】.NET 7 中的性能改进(七)
原文 | Stephen Toub 翻译 | 郑子铭 Arm64 在.NET 7中,大量的努力用于使Arm64的代码生成与x64的代码生成一样好或更好.我已经讨论了一些与架构无关的PR,还有一些是专门 ...
- OpenLayers之图形交互绘制
一.实验内容 回顾鼠标事件及事件对象,练习鼠标坐标获取: 点.线.面.圆等常规图形的交互绘制: 点.线.面.圆等常规图形的样式编辑: 点.线.面.圆等常规图形编辑: 二.实验步骤 2.1 鼠标坐标获取 ...
- Postgresql12基于时间点恢复
一.简介 数据库的PITR原理是依据之前的物理备份文件加上wal的预写日志模式备份做的恢复. 二.示例 1.数据库配置 wal_level = replica archive_mode = on ar ...
- LeetCode-398 随机数索引
来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/random-pick-index 题目描述 给定一个可能含有重复元素的整数数组,要求随机输出给定 ...
- 「JOI Open 2022」Giraffes 题解
设我们将要给出的观感好的排列为 \(q\),我们希望求出 \(\sum[p_i=q_i]\) 的最大值(这里指不移动的长颈鹿个数). 结论一:当且仅当左右端点有当前区间最大值或者最小值时条件才能成立. ...
- Pytorch和torchvision版本号对应表
torch与torchvision版本对应表 torch及torchvision版本号查询 import torch print(torch.__version__) import torchvisi ...
- python + pyqt 实现的你下载css背景图片的小工具(最终版)
学习python有三个星期了,算是做的第一个小工具,其实也没必要做成图形界面,只是为的GUI学习(再说技术总归给人使用的,熟练很多shell命令只是个"匠人".) win8下面: ...