Here is a simple regex expression...
document.getElementById('testing').value=f2.innerHTML.replace(">",">\n");
The problem is it stops a开发者_StackOverflow社区fter the first linebreak, how can I make it do the whole table?
Thanks!
Use .replace(/>/g, ">\n");
.
RegEx literal (or at least that's what I call it) uses two /
's. One to mark the begninning, one to mark the end. If you need to use an actual / in the replacement, you'll have to escape the / with a backslash (\). For example: /Hi\/Hello/
.
With RegEx literals, modifiers come after the last /
. In the case above, "g" means global and will replace all, not just the first one it comes to.
精彩评论