You almost have it. If you change (\w*) to (.*) your program produces what you want for the test case you have provided. You don't need the /g option on the substitution.
In reply to Re: Add at the begining of text
by ig
in thread Add at the begining of text
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |