12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- <!DOCTYPE html>
- <html lang="en">
- <meta charset="utf-8" />
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
- <title>Regex Tester</title>
- <script>
- function substitute() {
- pattern = document.getElementById('pattern').value;
- text = document.getElementById('text').value;
- prefix = document.getElementById('prefix').value;
- repl = document.getElementById('repl').value;
- suffix = document.getElementById('suffix').value;
- exp = new RegExp(pattern, 'g');
- result = prefix + text.replace(exp, repl) + suffix
- document.getElementById('result').value = result
- return false;
- }
- function copy() {
- document.getElementById('result').select();
- document.execCommand('copy');
- }
- </script>
- <form onsubmit="return substitute()">
- <p>pattern <input id="pattern" value="[\.,]\s+"></p>
- <p>text <input id="text"></p>
- <p>prefix <input id="prefix" value="<ul><li>"></p>
- <p>repl <input id="repl" value="</li><li>"></p>
- <p>suffix <input id="suffix" value="</li></ul>"></p>
- <p><input type="submit" value="substitute"></p>
- </form>
- <p>
- <textarea id="result"></textarea>
- <br>
- <input type="button" onclick="copy()" value="copy">
- </p>
- </html>
|