Last active
August 30, 2017 10:53
-
-
Save CMarzin/48bcd60b5c4109b218513f7a4c442fb1 to your computer and use it in GitHub Desktop.
Regex for terms and conditions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<title>regex terms and conditions</title> | |
</head> | |
<body></body> | |
<script> | |
var regex = /.*./g; | |
var str = `Copy paste here you terms and conditions directly from word/whatever`; | |
var m; | |
var arrayMatchToDisplay = []; | |
while ((m = regex.exec(str)) !== null) { | |
// This is necessary to avoid infinite loops with zero-width matches | |
if (m.index === regex.lastIndex) { | |
regex.lastIndex++; | |
} | |
m.forEach((match, groupIndex) => { | |
var regexMatch = `<p><p>${match}</p></p>`; | |
arrayMatchToDisplay.push(regexMatch); | |
}); | |
} | |
document.body.innerHTML = arrayMatchToDisplay.join('') | |
</script> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment