[Regular Expressions] Match the Start and End of a Line
We can use:
^: match the beginning
$: match the end
Let's say we have the string like the following:
var str = `//
--
//
--`;
What we want to do is get all the '12' which at the begining of each line:
If we do like that:
var regex = /^/g;

To solve this problem, we can use 'm' flag:
var regex = /^/gm;

And also we want to get the line which end by '16':
var regex = /^.+$/gm;

[Regular Expressions] Match the Start and End of a Line的更多相关文章
- [Regular Expressions] Match the Same String Twice
Regular Expression Backreferences provide us a method to match a previously captured pattern a secon ...
- 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] 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 ...
随机推荐
- Java清洁:终结处理和垃圾回收
一般情况:Java有垃圾回收机制负责回收无用对象占据的内存资源. 特殊情况:假定你的对象(并非使用new)获得一块特殊的内存区域,由于垃圾回收器只知道释放那些经由new分配的内存,所以它不知道如何释放 ...
- Ubuntu 12.04设置打开远程桌面登录1
teamviewer_linux.deb sudo dpkg --install teamviewer_linux.deb
- 关闭程序 提示 C#
private void Form1_FormClosing(object sender, FormClosingEventArgs e) { DialogResult dr = MessageBox ...
- QQ在线联系代码
添加图文模块,标题地址:tencent://message/?uin=你的QQ号&Site=myqq&Menu=yes "你的QQ号"就写您自己的Q号 图片地址写: ...
- sql 2000 分页
create PROCEDURE [dbo].[Proc_GetPageList] ( @Tables varchar(1000), --表名 @PK varchar(100 ...
- bug调试大全
http://www.jianshu.com/p/9fc9fd89bfee http://www.cocoachina.com/ios/20150929/13598.html
- 实现VS2010整合NUnit进行单元测试
1.下载安装NUnit(最新win版本为NUnit.3.2.1.msi) http://www.nunit.org/index.php?p=download 2.下载并安装VS的Visual Nuni ...
- hdu 1262寻找素数对
Problem Description 哥德巴赫猜想大家都知道一点吧.我们现在不是想证明这个结论,而是想在程序语言内部能够表示的数集中,任意取出一个偶数,来寻找两个素数,使得其和等于该偶数. 做好了这 ...
- artDialog的几种基本使用
1.confirm形式 var dialog=art.dialog({ lock:true, content: '请确认,您是否要删除选中的用吗?', icon: 'question', ok: fu ...
- CSS Reset方法
CSS Reset 即重设浏览器的样式.在各种浏览器中,都会对CSS的选择器默认一些数值,譬如当h1没有被设置数值时,显示一定大小. 但并不是所有的浏览器都使用一样的数值,所以,有了CSS Reset ...