[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 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的更多相关文章
- 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)使用笔记
Regular expressions are a powerful language for matching text patterns. This page gives a basic intr ...
- 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 ...
- 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 ...
- 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 ...
- Python re module (regular expressions)
regular expressions (RE) 简介 re模块是python中处理正在表达式的一个模块 r"""Support for regular expressi ...
随机推荐
- CCArray(转)
http://blog.csdn.net/passtome/article/details/7966451 CCArray也是cocos2d-x自己写的类.它相当于是objc的NSArray.在coc ...
- PHP页面之间跳转方法总结
编程中,在页面之间进行跳转是必须的.这里列出了三种办法,供参考. 一.用HTTP头信息 也就是用PHP的HEADER函数.PHP里的HEADER函数的作用就是向浏览器发出由HTTP协议规定的本来应该通 ...
- 显示目录树命令tree
-a:显示所有文件,包括隐藏文件 -d:只显示目录 -f:显示完整的文件名,包含路径 -L:显示目录树的深度 [root@rusky /]# tree -L -a -f /home /home |-- ...
- 使用OpenXml实现生成数据字典文档(beta)
最近项目在走验收流程,之前没有仔细看SOW文档,发现需要补好多份文档,其中就有数据字典,项目组不愿意花时间太多的时间弄这些文档,也不希望以后还要重复劳动力,最终决定做一个工具,方便自己生成数据字典文档 ...
- C#调用cmd 脚本实例
1.实例1 public static void TestOne() { Process p = new Process(); p.StartInfo.FileName = "cmd.exe ...
- CGRectInset CGRectoffset UIEdgeInsetsInsetRect 这三个函数的使用情况
//CGRectInset 将原来的矩形放大或者缩小,正表示缩小,-表示放大. CGRect rect= CGRectMake(20, 50, 100, 80); CGRect rect1=CGRec ...
- ios中模拟延时的几种方法
- (void)delay1 { // 延迟执行不要用sleep,坏处:卡住当前线程 [NSThread sleepForTimeInterval:3]; NSLog(@&qu ...
- Swift中构造器的继承和重写
import Foundation /* 构造器的继承: Swift的子类不会自动继承父类的构造器, 若继承, 则满足如下规则: 1.如果子类没有提供任何指定构造器, 那么它将自动继承父类的所有指定构 ...
- ArrayList 练习
ArrayList list = new ArrayList(); Random rd = new Random(); ; i <; i++) { , ); //是否包含当前数字 if (!li ...
- 东软实训4-JDBC连接数据库
JDBC(Java Data Base Connectivity,java数据库连接)是一种用于执行SQL语句的Java API,可以为多种关系数据库提供统一访问,它由一组用Java语言编写的类和接口 ...