[Regular Expressions] Find a String that Precedes Another String ?= , ?!
Let's image tow cases for the following string:
var str = `foo
foobar
foobaz
fooboo`
First of all: we know how to capture foobar or fooboo:
var regex = /foo(bar|boo)/g
1: We want to capture any 'foo' which followed by 'bar' or 'boo', but we do NOT want 'bar' or 'boo' appear in our result:
So we can use:
?=
so:
var regex = /foo(?=bar|boo)/g
2. We want to capture any 'foo' without 'bar' or 'boo' followed:
so we can use:
?!
so:
var regex = /foo(?!bar|boo)/g
[Regular Expressions] Find a String that Precedes Another String ?= , ?!的更多相关文章
- PCRE Perl Compatible Regular Expressions Learning
catalog . PCRE Introduction . pcre2api . pcre2jit . PCRE Programing 1. PCRE Introduction The PCRE li ...
- 8 Regular Expressions You Should Know
Regular expressions are a language of their own. When you learn a new programming language, they're ...
- Regular Expressions --正则表达式官方教程
http://docs.oracle.com/javase/tutorial/essential/regex/index.html This lesson explains how to use th ...
- Regular Expressions in Grep Command with 10 Examples --reference
Regular expressions are used to search and manipulate the text, based on the patterns. Most of the L ...
- [Regular Expressions] Find Plain Text Patterns
The simplest use of Regular Expressions is to find a plain text pattern. In this lesson we'll look a ...
- Introducing Regular Expressions 学习笔记
Introducing Regular Expressions 读书笔记 工具: regexbuddy:http://download.csdn.net/tag/regexbuddy%E7%A0%B4 ...
- [转]8 Regular Expressions You Should Know
Regular expressions are a language of their own. When you learn a new programming language, they're ...
- 正则表达式(Regular expressions)使用笔记
Regular expressions are a powerful language for matching text patterns. This page gives a basic intr ...
- 自学Zabbix8.1 Regular expressions 正则表达式
点击返回:自学Zabbix之路 点击返回:自学Zabbix4.0之路 点击返回:自学zabbix集锦 自学Zabbix8.1 Regular expressions 正则表达式 1. 配置 点击Adm ...
随机推荐
- C#基础:C#4.0权威指南 杂笔一
1.c#中数组初始化的几种不同用法 int[] name = new int[NUM]; int[] name = {1, 2, 3, 4, 5, 6}; int[] ...
- Material Design说明
原文链接: Material Design 引言 我们挑战自我,为用户创造了一种视觉语言,综合了好设计的经典原则,革新以及科技的可能性.这就是material design.这份说明是一个动态的文档, ...
- iOS_SN_Socket网络编程(一)
1.Socket简介 首先让我们通过一张图知道socket在哪里? socket在哪里 Socket是应用层与TCP/IP协议族通信的中间软件抽象层,它是一组接口. 2.TCP和UDP的区别 在这里就 ...
- UIView / UIView的布局
//! 一个视图可以有n个子视图,但是一个视图只能有一个父视图 struct CGRect { CGPoint origin; CGSize size; }; CGRectMake(CGFlo ...
- Windows环境变量修改
做开发的时候都设置过Windows的环境变量,一直觉得实在是难用之极.网上搜索过解决方案,有个开源的小程序,试过,有问题,没有办法正常运行.所以自己写一个,权当练手. 下载地址:http://file ...
- UWP开发小记
针对个人的上一篇文章中提到的遇到的几个问题,做一下个人解答 DLL部署的问题,可以将DLL添加到工程中,属性中设置content为true,这样,部署目录下就会有这个文件. 需要说明的是,这个文件确实 ...
- apache将请求转发到到tomcat应用
映射: 1.开启apache中的proxy模块(proxy.conf,proxy.load,proxy_http.load) 2.配置apache配置文件,<VirtualHost *:80&g ...
- Symfony2 Doctrine从现有Database生成Entity(转载自http://blog.it985.com/6809.html)
在我的以前一章Symfony之十分钟入门说了怎样生成数据库,然后设计实体Entity,再同步数据库的表结构,一般我们的顺序都是这样:生成数据库->设计实体Entity->同步数据库表结构. ...
- 前端jquery实现点击图片弹出大图层(且滚动鼠标滑轮图片缩放)
<img src="{$vo.photo}" height="50px" onclick="showdiv({$i});"> & ...
- CSU 1119 Collecting Coins
bfs+dfs 很复杂的搜索题. 因为数据很小,rock最多只有5个,coin最多只有10个,移动rock最多4^5=1024种状态: 思路: 每次先把当前状态能拿到的coin拿走,并将地图当前位置设 ...