[Regular Expressions] Find the Start and End of Whole Words
Regular Expression Word Boundaries allow to perform "whole word only" searches within our source string.
var str = `This history is his, it is`;
The easiest way is using : \b
\b //catch the whole word;
\bis // catch the 'is', which in the beginning of the word
is\b // catch the 'is', which in the end of the word
\bis\b //catch only 'is', with nothing else
Catch start with 'is':
var regex = /\bis/g
Catch end with 'is':
var regex = /is\b/g
Catch only 'is':
var regex = /\bis\b/g
Also '\B' has the oppset meanings with '\b':
\Bis // catch 'is', which is NOT at the beginng
is\B // catch 'is', which is NOT at the end
\Bis\B //catch 'is', which it neither at beginng or end
Not at the begining:
var regex = /\Bis/g
Not at the end:
var regex = /is\B/g
Neither begining nor end:
var regex = /\Bis\B/g
The same effect as previous one.
[Regular Expressions] Find the Start and End of Whole Words的更多相关文章
- 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 ...
- 转载:邮箱正则表达式Comparing E-mail Address Validating Regular Expressions
Comparing E-mail Address Validating Regular Expressions Updated: 2/3/2012 Summary This page compares ...
- 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 ...
- [Regular Expressions] Introduction
var str = "Is this This?"; //var regex = new RegExp("is", "gi"); var r ...
- 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 ...
随机推荐
- [CSS] :not Selector
The CSS :not() selector allows us to exclude a subset of elements matched by our selector. In this e ...
- css3 tranform transition animation
tranform:对象图形变形 tranform的属性包括: 1.none 表示不进行变换: 2.rotate 旋转 transform:rotate(20deg) 旋转 ...
- redis的备份和恢复
Redis 数据备份与恢复 数据备份 语法 redis Save 命令基本语法如下: redis > SAVE 实例 redis > SAVE OK 该命令将在 redis 备份目录中创建 ...
- BZOJ 3277 串 (广义后缀自动机)
3277: 串 Time Limit: 10 Sec Memory Limit: 128 MB Submit: 309 Solved: 118 [Submit][Status][Discuss] De ...
- Python代码一定要对齐
不然会出现错误: IndentationError: unindent does not match any outer indentation level PS:新的Python语法,是不支持的代码 ...
- html label 标签的 for 属性
如果您在 label 元素内点击文本,就会触发此控件.就是说,当用户选择该标签时,浏览器就会自动将焦点转到和标签相关的表单控件上. 有两种使用方法: 方法1 使用for属性 <label for ...
- mysql grant all privileges on
遇到了 SQLException: access denied for @'localhost' (using password: no) 解决办法 grant all privileges on * ...
- 在windows中搭建php开发环境
一.wampserver wampserver是一个安装集成包,包含了开发所需的apache,mysql,php,简单方便. 下载地址 http://www.xiazaiba.com/html/279 ...
- Web项目中用模板Jsp页面引入所有静态样式脚本文件(js,css等)
这样的好处是不需要再每个页面中都添加太多的外链接(不会减少请求数量),但对开发会更快捷,如果更改这些文件的位置或名称,只需要更改模板文件,不需要一个一个页面复制粘贴:同时可以为不同jsp页面组创建不同 ...
- 搭建phonegap开发环境,搭建安卓开发环境
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http ...