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的更多相关文章

  1. XSS Filter Evasion Cheat Sheet 中文版

    前言 译者注: 翻译本文的最初原因是当我自己看到这篇文章后,觉得它是非常有价值.但是这么著名的一个备忘录却一直没有人把它翻译成中文版.很多人仅仅是简单的把文中的 各种代码复制下来,然后看起来很刁的发在 ...

  2. [转]Blue Prism VBO Cheat Sheet

    本文转自:https://www.cheatography.com/ethanium/cheat-sheets/blue-prism-vbo/ Blue Prism MAPIEx Configure ...

  3. Tools - 速查表与备忘单(Cheat Sheet)

    Cheat Sheets Rico's cheatsheets Cheat-Sheets.org Python Python Cheat sheet Python Programming Cheat ...

  4. 转:PostgreSQL Cheat Sheet

    PostgreSQL Cheat Sheet CREATE DATABASE CREATE DATABASE dbName; CREATE TABLE (with auto numbering int ...

  5. Git Cheat Sheet

    Merge Undo git merge with conflicts $ git merge --abort Archive $ git archive --format zip --output ...

  6. CSS3 Animation Cheat Sheet:实用的 CSS3 动画库

    CSS3 Animation Cheat Sheet 是一组预设的动画库,为您的 Web 项目添加各种很炫的动画.所有你需要做的是添加样式表到你的网站,为你想要添加动画效果的元素应用预制的 CSS 类 ...

  7. XSS (Cross Site Scripting) Prevention Cheat Sheet(XSS防护检查单)

    本文是 XSS防御检查单的翻译版本 https://www.owasp.org/index.php/XSS_%28Cross_Site_Scripting%29_Prevention_Cheat_Sh ...

  8. IOS Application Security Testing Cheat Sheet

    IOS Application Security Testing Cheat Sheet    [hide]  1 DRAFT CHEAT SHEET - WORK IN PROGRESS 2 Int ...

  9. HTML5 Cheat sheet PNG帮助手册(标签、事件、兼容)

    HTML5 Cheat sheet PNG帮助手册(标签.事件.兼容) 1.HTML5标签 2.HTML5事件 3.HTML5兼容 最新HTML5手册资料请参考:http://www.inmotion ...

  10. [转]Swift Cheat Sheet

    原文:http://kpbp.github.io/swiftcheatsheet/ A quick cheat sheet and reference guide for Apple's Swift ...

随机推荐

  1. PDO使用返回结果集的方法输出数据库里面的单个值

    1 <?php 2 header('content-type:text/html; charset=utf-8'); 3 /* 通过调用驱动程序创建一个PDO实例 */ 4 $dsn = 'my ...

  2. JR文摘_TNFi和阿贝西普降低RA患者CVD风险

    转自 Dr Jack Cush的Twitter (2020-08-19) JR文摘: 18754例RA患者前瞻性观察到1801次CVD事件,与csDMARDs相比, TNFi(HR: 0.82, 95 ...

  3. STM32L4 Keil ST-Link 连接失败

    ST-LINK 连接失败的因素,以我个人的经历而言有两种:一个是驱动问题,一个是插线问题.连接正常的情况如下图所示,SWDIO 能显示你的设备信息: 注意使用 SW 端口,JTAG 端口导致无法识别设 ...

  4. 基于GLUT的PyOpenGL的使用

    1. GLUT概述 OpenGL只是一种规范,不仅语言无关,而且平台无关.规范只字未提获得和管理OpenGL上下文相关的内容,而是将这些作为细节交给底层的窗口系统.出于同样的原因,OpenGL纯粹专注 ...

  5. Ubuntu 安装 PHP

    Ubuntu版本:20.04.1 LTS PHP版本:8.2.3 下载地址: https://www.php.net/downloads 官方文档:https://www.php.net/manual ...

  6. 关于vue组件传值和事件绑定问题

    <template> <view style="width: 100%; height: 100%;"> <view class="tabs ...

  7. CF1404D 题解

    题意 传送门 给定 \(2n\) 个数 \(1,2,\dots,2n\),A 和 B 进行交互,如下规则: A 需要将元素分成 \(n\) 组 \(\texttt{pair}\): B 从每组 \(\ ...

  8. LinkedList的线程安全解决办法

    方法一:List<String> list = Collections.synchronizedList(new LinkedList<String>()); 方法二:将Lin ...

  9. Qt 3D示例——cube

    Qt 3D官方示例 cube的3D演示,一个纯C++的项目.虽然QML示例比较炫,但是要深入理解还是得从C++例子入手. 从MainWidget.show入口.一步步可以跟踪到initializeGL ...

  10. OpenStack 卷虚拟机跨租户迁移方案

    目标:迁移租户A的卷虚机到租户B 场景:使用卷虚拟机,租户a和b使用相同网络 租户A的操作: 1.记录虚拟机的ip地址,Mac信息, nova interface-list neutron port- ...