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的更多相关文章

  1. [Regular Expressions] Match the Same String Twice

    Regular Expression Backreferences provide us a method to match a previously captured pattern a secon ...

  2. PCRE Perl Compatible Regular Expressions Learning

    catalog . PCRE Introduction . pcre2api . pcre2jit . PCRE Programing 1. PCRE Introduction The PCRE li ...

  3. 8 Regular Expressions You Should Know

    Regular expressions are a language of their own. When you learn a new programming language, they're ...

  4. Regular Expressions --正则表达式官方教程

    http://docs.oracle.com/javase/tutorial/essential/regex/index.html This lesson explains how to use th ...

  5. 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 ...

  6. [Regular Expressions] Introduction

    var str = "Is this This?"; //var regex = new RegExp("is", "gi"); var r ...

  7. Introducing Regular Expressions 学习笔记

    Introducing Regular Expressions 读书笔记 工具: regexbuddy:http://download.csdn.net/tag/regexbuddy%E7%A0%B4 ...

  8. [转]8 Regular Expressions You Should Know

    Regular expressions are a language of their own. When you learn a new programming language, they're ...

  9. 正则表达式(Regular expressions)使用笔记

    Regular expressions are a powerful language for matching text patterns. This page gives a basic intr ...

随机推荐

  1. python (3):wxPython打包app,报错

    1,打包app报错 如图: 使用py2app,mac下打包成app.异常.程序直接退出. 没有详细的错误信息,client程序直接崩溃了. 2.原因 代码没有几行: #!/usr/bin/python ...

  2. DotNet程序汉化过程--SnippetCompiler简单解说

    SnippetCompiler介绍 平时要验证一段C#代码或者写一个算法,就得打开庞大的VS新建一个解决方案,占用了硬盘空间不说还费时费力.SnippetCompiler这个工具就可以在这里帮到我们了 ...

  3. html中行内元素与块级元素的区别。

    在标准文档流里面,块级元素具有以下特点 1.总是在新行上开始,占据一整行: 2.高度,行高以及外边框和内边距都可以控制: 3.宽度始终是与游览器宽度一样,与内容无关: 4.它可以容纳内联元素和其他块级 ...

  4. Sqlserver统计语句

    --查看被缓存的查询计划 SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED st.text AS [SQL] , cp.cacheobjtype , c ...

  5. Asp.net中具体的日期格式化用法

    1.绑定时格式化日期方法: <ASP:BOUNDCOLUMN DATAFIELD= "JoinTime " DATAFORMATSTRING= "{0:yyyy-M ...

  6. PowerDesigner Mysql 主键自增、初始值、字符集

    自增 在你所要设为自增型的键上(比如你的id)双击,弹出一个Column Properties对话框,右下角有一个Identify的选择框,选中它OK,就可以了. 再去查看Preview,就能看到AU ...

  7. oracle包详解(二)【weber出品】

    一.重载子程序 PL/SQL中的重载功能: 1. 能够使用户创建两个或多个同名的子程序 2. 要求子程序的形式参数的数量,顺序或者数据类型不一样 3. 能够使用户使用不同的数据灵活的调用子程序 4. ...

  8. 介绍 Visifire 常用属性的设置

    转载自http://www.cnblogs.com/xinyus/p/3422198.html 主要介绍 Visifire 常用属性的设置,用来生成不同样式的图例 设置Chart的属 //设置titl ...

  9. ios--图片处理(修改、保存)UIGraphicsBeginImageContext

    http://www.th7.cn/Program/IOS/201407/250904.shtml

  10. FCKeditor 插件开发 示例

    (FCKeditor.地址是:http://www.fckeditor.net/.我下载的版本是:2.6.3.)What ?FCKeditor一直是web上编辑器的比较好的一个选择,他是开源的,而且效 ...