[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 ...
随机推荐
- ajax(ajax开发)
AJAX即“Asynchronous Javascript And XML”(异步JavaScript和XML),是指一种创建交互式网页应用的网页开发技术. AJAX = 异步 JavaScript和 ...
- c#转码解码
///反转码 mdata[k].MNAME = unescape(mdata[k].MNAME);程家楠 13:51:00 Microsoft.JSc ...
- EF数据存贮问题二之“无法定义这两个对象之间的关系,因为它们附加到不同的 ObjectContext 对象”
“无法定义这两个对象之间的关系,因为它们附加到不同的 ObjectContext 对象”,这是在EF中,一对多关系表,有外键的类保存至数据库中出现的错误. 我原来是用JAVA开发的,习惯性的处理一对多 ...
- Android黑科技,读取用户短信+修改系统短信数据库
安卓系统比起ios系统最大的缺点,相信大家都知道,就是系统安全问题.这篇博客就秀一波“黑科技”. 读取用户短信 Android应用能读取用户手机上的短信,相信已经不是什么新鲜事,比如我们收到的短信验证 ...
- AngularJs练习Demo10 ngInclude
@{ Layout = null; } <!DOCTYPE html> <html> <head> <meta name="viewport&quo ...
- 集合运算符之全集、交集、补集【weber出品必属精品】
集合的概念 与数学中的全集.交集.补集的概念是一样的 常用的集合运算符 集合运算符的作用:把两个查询构造为一个联合查询 1. 全集:求连个查询的全集 union all:将两个查询的所有数据全部列出, ...
- wcf wpf
转 http://blog.csdn.net/thunder09/article/details/5792157 WPF就是所谓下一代Windows界面层技术,我觉得还有满有前途的.不过Vista发布 ...
- 探索A@1db9742
public class S { /** * @param args */ public static void main(String[] args) { System.out.printl ...
- hdu1215 正整数唯一分解定理应用
B - (例题)因子和 Crawling in process... Crawling failed Time Limit:1000MS Memory Limit:32768KB 64 ...
- UVA442 栈
C - Matrix Chain Multiplication Crawling in process... Crawling failed Time Limit:3000MS Memory ...