Результаты поиска по запросу "javascript regex replace group":

    1. regex - Javascript replace with reference to matched group? - Stack Overflow

      • Java RegExp Replace. -3. javascript | find and replace quote using regex.
      • 850. How do you access the matched groups in a JavaScript regular expression? 6961. How to redirect to another webpage?


    2. regex - Javascript replace matched group - Stack Overflow

      You can capture the parts you don't want to replace and include them in the replacement string with $ followed by the group number: S.replace(/(\w)\n(\w)/g, "$1<br />\n$2"); See this section in the MDN docs for more info on referring to parts of the input string in your replacement string.


    3. Replace a Regex capture group with uppercase in Javascript - Stack Overflow

      Since you are using the special replace syntax ($N grabs the Nth capture) you are simply giving the same value. The toUpperCase is actually deceiving because you are only making the replace string upper case...


    4. JavaScript RegExp Object - Using Regular Expressions with Client Side Scripting

      • The String.replace() function interprets several placeholders in the replacement text string. If the regexp contains capturing groups, you can use backreferences in the replacement text.
      • I have created an example web page showing JavaScript's regex support in action.


    5. javascript - JS Regex, how to replace the captured groups only? - Stack Overflow

      A solution is to add captures for the preceding and following text: Str.replace(/(.*value="\w+)(\d+)(\w+".*)/, "$1!NEW_ID!$3").


    6. Named capturing groups in JavaScript regex? - Stack Overflow

      Let's say you want to add a zero to a digit and therefore want to replace (\d) with $10. In JavaScript, this will work (as long as you have fewer than 10 capturing group in your regex), but Perl will think you're looking for backreference number 10 instead of number 1, followed by a 0. In Perl, you can use...


    7. javascript - Multiple Regex replace - Stack Overflow

      • How to use JavaScript regex over multiple lines? 252. Regex to replace multiple spaces with a single space.
      • Regex replace groups multiple times.


    8. Special $ References In JavaScript's String.replace() Method

      • Using Regular Expressions In Javascript (A General Overview). Ask Ben: Javascript Replace And Multiple Lines / Line Breaks.
      • Regular expressions are literals in ECMAscript. Every regex function is available everywhere. Ben Nadel May 25, 2011 at 5:01 PM.


    9. Referencing nested groups in JavaScript using string replace using regex - Stack Overflow

      I'm thinking that regular expressions by themselves can't do exactly what I'm looking for, so here's my modification to work around the problem: Var scriptTagFormat = /<script\s+((. ... )*\s*>(.*?)<\/script>/ig; Html = html.replace( scriptTagFormat, '<span class...


    10. Regular Expressions - JavaScript | MDN | Mozilla Developer Network

      • In JavaScript, regular expressions are also objects. These patterns are used with the exec and
      • In the replacement part of a regex the syntax $1, $2, $n must be used, e.g.: 'bar foo'.replace
      • Note: JavaScript's regular expression engine defines a specific set of characters to be "word" characters.