The simplest use of Regular Expressions is to find a plain text pattern. In this lesson we'll look at at finding plain text patterns as well as using the metacharacter "." and how to escape a metacharacter.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Javascript Regular Expressions: Find Plain Text Patterns</title>
<style>
pre {
line-height: 2;
}
span {
background-color: #eee;
padding: 1px;
outline: 1px solid #999;
}
</style>
</head>
<body>
<pre></pre>
</body>
</html>
'use strict';

var str = `Cat
sat on
the hat.`;
var regex = /..\./g //any two charaters follow by a '.' /**
* @param String str
* @param RegExp regex
* @param HTMLElement target
*/
const output = (str, regex, target) => {
target.innerHTML =
str.replace(regex, str =>
`<span>${str}</span>`
);
}
output(str, regex, document.querySelector('pre'));

[Regular Expressions] Find Plain Text Patterns的更多相关文章

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

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

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

  3. PCRE Perl Compatible Regular Expressions Learning

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

  4. 8 Regular Expressions You Should Know

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

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

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

  6. Introducing Regular Expressions 学习笔记

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

  7. [转]8 Regular Expressions You Should Know

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

  8. Finding Comments in Source Code Using Regular Expressions

    Many text editors have advanced find (and replace) features. When I’m programming, I like to use an ...

  9. Python re module (regular expressions)

    regular expressions (RE) 简介 re模块是python中处理正在表达式的一个模块 r"""Support for regular expressi ...

随机推荐

  1. HBase学习(十四)LINUX下用Eclipse构建HBase开发环境

    Eclipse,HBase版本号眼下没有发现须要特别指定 1:从HBase集群中复制一份Hbase部署文件,放置在开发端某一文件夹下(如在/app/hadoop/hbase096文件夹下). 2:在e ...

  2. Ajax原生XHR对象

    前端学了有一段时间了,在项目中我通常使用的都是jQuery封装好的Ajax函数($.ajax.$.get.$.post),使用非常的简单方便,但为了更清楚的了解Ajax,需要学习原生xhr对象.   ...

  3. [iOS]使用symbolicatecrash分析crash文件

    对于我们iOS开发者来说,最心碎的事莫过于苹果审核一个星期后上架app store,而第二天就报出闪退bug.一周前我刚经历过,而且最坑的是由于第一次做个人开发,经验不足,没有集成友盟的分析SDK,还 ...

  4. 【iOS之runtime、runloop】

    什么是runtime runtime就是运行时,是系统在运行时的一些动态机制,它是一套底层的API,我们平时编写的OC代码,最终会转换为runtime实现. runtime的作用 可以利用runtim ...

  5. eclipse打包 jar文件,中文乱码解决方案

    直接通过eclipse浏览源代码时,发现中文注释为乱码的问题.其实这个eclipse默认编码造成的问题.可以通过以下方法解决: 修改Eclipse中文本文件的默认编码:windows->Pref ...

  6. js操作符

    JS操作符 x + y(数字) 将x和y相加; x + y(字符串) 将x和y拼接在一起; x - y 从x中减去y; x * y 将x和y相乘; x / y 将x除以y; x % y x和y的模(既 ...

  7. (转)WITH (NOLOCK)

    缺点: 1.会产生脏读 2.只适用与select查询语句 优点: 1.有些文件说,加了WITH (NOLOCK)的SQL查询效率可以增加33%. 2.可以用于inner join 语句 脏读: 一个用 ...

  8. Swift--控制流与oc不同的地方

    1.For-in循环中... for index in 1...5 { print("\(index) times 5 is \(index * 5)") } for _ in 1 ...

  9. Swift缩水版MJExtension - Reflect的基本使用

    github:https://github.com/CharlinFeng/Reflect 直接拖拽Reflect文件夹到您的项目中即可,无任何第三方依赖!文件夹结构说明:.Coding 归档相关.R ...

  10. 动态代理写connection连接池Demo

    public class JdbcUtil2 { //声明连接池<放到LinkedList中,操作其中对象的速度快 只需要改变连接> private static LinkedList&l ...