This simple tutorial is about how to parse text file using a regular expression, or called regex or regexp.
This text processing is very useful to programmers.
The parking area is filled with the source code numbered as input.
Using the javascript function named RemoveFirstLineNumbers will retrieve and process the input text by deleting the numbers.
Any regular expression for text processing can be used.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Page Title</title> </head> <body onload="document.getElementById('textarea').focus()"> <script type="text/javascript"> var reg = new RegExp("^\\s*\\d+\\.?", "gm"); function RemoveFirstLineNumbers(textArea) { textArea.value = textArea.value.replace(reg, ""); } </script> <textarea id="textarea" onkeyup="RemoveFirstLineNumbers(this)" rows="100" cols="50">Paste your code source to remove the first line numbers of each row.</textarea> </body> </html> |