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

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -