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 ...
随机推荐
- day15-SpringMVC执行流程
SpringMVC执行流程 1.SpringMVC执行流程分析图 例子 (1)创建 HaloHandler package com.li.web.debug; import org.springfra ...
- 题解 [SCOI2008]斜堆
好题.一道很有趣的性质提. 因为自己搞错结论然后改了 1h(悲 闲话少说,切入正题-- 这是不断插入的,所以根据套路我们会考虑最后一个插入的节点的性质.显然满足: 它是从根不停往左走的路上. 它没有右 ...
- 云服务器安装 redis
下载地址:https://download.redis.io/releases/ 此处示例使用的版本是:redis-6.2.10.tar.gz 前提环境: 云服务器 Xshell(操作终端) Xftp ...
- Prometheus插件安装(NodeExporter)
Prometheus插件安装(NodeExporter) 一,下载安装包并解压 下载地址:https://github.com/prometheus/node_exporter/releases 同样 ...
- mysql查询重复的数据
---查询重复的数据 . UUID可以换成其他的需要去重的字段. 点击查看代码 select * FROM t_gzmx_reptile_receive_incre WHERE id NOT IN ( ...
- windows10 远程桌面黑屏
[计算机配置]-[管理模板]-[Windows组件]-[远程桌面服务]-[远程桌面会话主机]-[远程会话环境]-{为远程桌面连接使用WDDM图形显示驱动程序-设置禁用}
- 分时问候——时间类、if语句
import java.time.LocalTime; public class Hello { public static void main(String[] args) { LocalTime ...
- cisco的telnet远程登入
Cisco配置telnet登入 拓扑图: IP地址表: 设备 IP地址 PC0 192.168.1.1 Switch0 vlan1:192.168.1.254 1.不需要用户的telnet登入 Swi ...
- (jmeter笔记)jmeter用正则匹配响应数据,满足两个条件
方法1.用正则匹配响应数据,满足两个条件 \{[^}]+?"Id":(\d*)[^}]+?"Picking"[^}]+?\} 方法2. \{"Pick ...
- 【Java】Object
Object转Map import com.alibaba.fastjson.JSON; import com.runsky.utils.JsonUtils; String objectToJson ...