Skip to content
This repository has been archived by the owner on Jan 24, 2023. It is now read-only.

Commit

Permalink
Add regex for js introduction
Browse files Browse the repository at this point in the history
Setting up simple regex sample
  • Loading branch information
sicktastic committed May 9, 2016
1 parent 3402e8d commit 77e7a99
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 0 deletions.
Binary file added regular-expressions/.introduction.html.swp
Binary file not shown.
Binary file added regular-expressions/.introduction.js.swp
Binary file not shown.
21 changes: 21 additions & 0 deletions regular-expressions/introduction.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Regular Expression Introduction</title>
<style>
pre {
line-height: 2;
}
span {
background-color: #eee;
padding: 1px;
outline: 1px solid #999;
}
</style>
</head>
<body>
<pre></pre>
<script src="introduction.js"></script>
</html>
19 changes: 19 additions & 0 deletions regular-expressions/introduction.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"use strict";

const output = (str, regex, target) => {
target.innerHTML(regex, str => '<span>{str}</span>');
}

var str = "Is this This?";

// var regex = new RegExp("is", "g);
// g = global, i=ignore case
var regex = /is/gi;


// console.log(regex.test(str));
// console.log(regex.exec(str))
// console.log(str.match(regex))
// console.log(str.replace(regex, str => "XX"))

output(str, regex, document.querySelector('pre'))

0 comments on commit 77e7a99

Please sign in to comment.