[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 ...
随机推荐
- HDU--1584--蜘蛛牌--深搜版本号
蜘蛛牌 Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submi ...
- C#使用checked关键字处理"溢出"错误
代码如下: private void btnCalculate_Click(object sender, EventArgs e) { byte num1, num2;//定义两个byte变量 if( ...
- java基础之String
字符串的含义 字符串的应用 字符串的方法
- 关闭程序 提示 C#
private void Form1_FormClosing(object sender, FormClosingEventArgs e) { DialogResult dr = MessageBox ...
- OC基础 可变字典与不可变字典的使用
OC基础 可变字典与不可变字典的使用 1.不可变字典 1.1创建不可变字典 //创建字典 //注意: //1,元素个数是偶数 //2,每两个元素是一个键值对 //3,值在前,键在后 NSDiction ...
- c#串口编程时,忽略跨线程检查报错
1.直接在main_Form_Load的初始化中加 //忽略跨线程检查 // System.Windows.Forms.Control.CheckForIllegalCrossThreadCalls ...
- 伪协议触发onbeforeunload
根据MSDN描述,IE的onbeforeunload事件触发条件: 简单点来说就是页面URL发生改变时触发: * 关闭浏览器窗口 * 点击后退.前进.刷新.主页 * 点击链接到新页面 * 调用超链接的 ...
- nodejs应用mysql(纯属翻译)
原文点击这里 目录 Install Introduction Contributors Sponsors Community Establishing connections Connection o ...
- mysql 套事物实例
public static DataSet GetPPriceList(string aircompany, string departPort, string arrivePort, string ...
- SQL Server聚合函数
聚合函数对一组值计算后返回单个值.除了count(统计项数)函数以外,其他的聚合函数在计算式都会忽略空值(null).所有的聚合函数均为确定性函数.即任何时候使用一组相同的输入值调用聚合函数执行后的返 ...