Skip to content

Instantly share code, notes, and snippets.

@Musinux
Last active July 8, 2020 22:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Musinux/2ee602fd6d0a764bf8d0fc3374bf73ca to your computer and use it in GitHub Desktop.
Save Musinux/2ee602fd6d0a764bf8d0fc3374bf73ca to your computer and use it in GitHub Desktop.
<html>
<head>
<meta charset="utf-8">
<style>
#entree {
width: 100%;
height: 300px;
}
#regex {
width: 100%;
}
</style>
<script>
function testRegex () {
const regexText = document.querySelector("#regex").value
const content = document.querySelector("#entree").value.split('\n')
const resultat = document.querySelector("#resultat")
const regex = new RegExp(regexText);
console.log('regex', regex);
console.log('content', content);
const output = content.map(c => c.match(regex))
console.log('result', output);
resultat.textContent = JSON.stringify(output, null, 2);
}
</script>
</head>
<body>
<textarea id="entree"></textarea>
<br>
<input type="text" id="regex">
<br>
<button onclick="testRegex()">Tester la regex</button>
<h1>Résultat:</h1>
<pre id="resultat"></pre>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment