[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 ...
随机推荐
- java基础之代理
代理的定义,代理的应用,代理的特性
- jquery之null的数组
去掉null的数组 function ClearNullArr(arr) { for (var i = 0; i < arr.length; i++) { if(arr[ ...
- oracle数据库事务相关【weber出品必属精品】
事务的概念:事务:一个事务由一组构成一个逻辑操作的DML语句组成 事务有开始有结束,事务以DML语句开始,以Conmmit和Rollback结束.以下情况会使得事务结束: 1. 执行COMMIT 或者 ...
- 0301——Notification 通知
注册消息 [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(方法) name:@"消息名字&q ...
- Oracle 10g体系结构及安全管理
(1) Oracle数据库服务器:数据库,实例 (2) 数据库:(1)物理存储—数据文件,控制文件,日志文件,(2)逻辑存储—表空间,段,区间, ...
- 转载:js实现上传图片时 点击浏览后 就可以看到缩略图 很实用
转载网址:http://blog.sina.com.cn/s/blog_6094f04d0100o6kj.html <!DOCTYPE html PUBLIC "-//W3C//DTD ...
- 百度地图api实例
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm11.aspx ...
- HBase架构深度解析
原文出处: DLevin(@雪地脚印_) 前记 公司内部使用的是MapR版本的Hadoop生态系统,因而从MapR的官网看到了这篇文文章:An In-Depth Look at the HBase A ...
- python作业day3修改配置文件
思维还有点乱,撸代码到深夜,先上代码吧.(我是跟着武sir的思路的) 流程图: 代码(有注释): #!/usr/bin/env python # -*- coding:utf-8 -*- import ...
- 在UC浏览器上很炫的一个效果
效果简述: 这个效果将会强行去除UC浏览器的网址输入框和底部的菜单栏,这样网页将会占据整个手机界面.感觉看起来很像是一个APP. 浏览器界面右下角将会出现一个向上的标志,用来唤出简单的菜单栏. (界面 ...