[JavaScript] Append Text at the Beginning of Each Line
Paste your lines below:
Lines after prepended:
The first textarea is the lines to be prepended. The second textarea is the lines after prepended. The JavaScript code to append text at the beginning of each line is:
afterTextareaElm.value = oriTextareaElm.value.replace(/^/gm, inputElm.value);
- ^ means beginning of line.
- g means global match
- m means multiline matching
If you are not familiar with JavaScript regular expression, see [3].
References:
| [1] | Search Links of Major Search Engines |
| [2] | [sed] Append Text at the Beginning of Each Line |
| [3] |
| [4] | css - HTML Textarea isn't responsive - Stack Overflow |