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 ...
随机推荐
- JZOJ 100019.A
\(\text{Problem}\) \(\text{Solution}\) 把形如 \((a,ka)\) 的路径提出来 那么覆盖这些路径的路径为不合法路径 如果能不重不漏的找出这些路径,然后用总路径 ...
- 代码随想录算法训练营day24 | leetcode 77. 组合
基础知识 回溯法解决的问题都可以抽象为树形结构,集合的大小就构成了树的宽度,递归的深度构成的树的深度 void backtracking(参数) { if (终止条件) { 存放结果; return; ...
- 微信小程序防止多次点击提交的方法
Page({ data: { lock: false }, //表单提交 submit(){ let that = this; let {lock} = that.data; if(!lock){ t ...
- 优化 Win11 资源管理器打开文件夹速度
打开"高级系统设置",点击"性能"设置,性能选项中勾选如上图选中的项,可以一定程度上提升 Win11 资源管理器打开文件夹的速度: "窗口内动画控件和 ...
- Android:LitePal 在第一次创建表之后第二次创建新的表不生效
因为业务需求的增长,后续需要继续创建新的表,有可能代码没有任何报错,同时数据库也没有任何新的表加入进来. 修改 litepal.xml 的 version,如果之前是 1,那么修改为 2,总之比之前 ...
- CSS transform: scale()
前言 transform属性允许你旋转,缩放,倾斜或平移给定元素.其中scale(x, y)就是实现元素缩放的属性值. scale(x, y)的 x 乘以原本元素的 x:y 乘以原本的元素 y,就可以 ...
- PostGIS之空间投影
1. 概述 PostGIS 是PostgreSQL数据库一个空间数据库扩展,它添加了对地理对象的支持,允许在 SQL 中运行空间查询 PostGIS官网:About PostGIS | PostGIS ...
- npm+react linux 开荒
安装npm 从 https://nodejs.org/dist/ 找到下载包,并不是版本越高越好,得看项目的需要. 解压之后,将解压路径bin添加到PATH里. 完成后可配置npm源 npm inst ...
- python 在一个文件夹的所有文件中查找关键字
python 在一个文件夹的所有文件中查找关键字 import os,shutil import re key='Hello' re_parttern=re.compile(r''+key,re.DO ...
- Day 22 22.3:生产者和消费者模式
生产者消费者模式 认识生产者和消费者模式 生产者和消费者是异步爬虫中很常见的一个问题.产生数据的模块,我们称之为生产者,而处理数据的模块,就称为消费者. 例如: 图片数据爬取中,解析出图片链接的操 ...