What does this Regex want to do in JavaScript? -
what regex in javascript?
function fn (str) { str.replace(/((^|%>)[^\t]*)/g, "$1\r"); }
edit: op changed/clarified question , wanted provide more detail.
the regular expression looking for:
- the start of line
^or|following symbol sequence:%>followed by: - any number
*of characters[...]not^tab symbols (\t)
the global switch g ensures matches evaluated. replacement $1 inserts first captured sequence indicated parentheses, happens entire matched string followed carriage return \r.
as javascript exists, nothing done replacement, since .replace(...) method returns new string rather modifying string upon evaluation contextualized.
Comments
Post a Comment