A solution is to add captures for the preceding and following text:
str.replace(/(.*name="\w+)(\d+)(\w+".*)/, "$1!NEW_ID!$3")
More Related Contents:
- Find list of strings that matches a pattern that start with a special character « and end with a special character »
- Remove text between two parenthesis, if two more parenthesis [closed]
- How to replace plain URLs with links?
- Regular expression to get a string between two strings in Javascript
- Regex to get string between curly braces
- Validate phone number with JavaScript
- What is the meaning of the ‘g’ flag in regular expressions?
- What is the difference between RegExp’s exec() function and String’s match() function?
- Is there a version of JavaScript’s String.indexOf() that allows for regular expressions?
- Matching a Forward Slash with a regex
- How to find a number in a string using JavaScript?
- How can I concatenate regex literals in JavaScript?
- escaping question mark in regex javascript
- Javascript regex (negative) lookbehind not working in firefox
- JavaScript/regex: Remove text between parentheses
- JavaScript Regex, where to use escape characters?
- javascript regex for password containing at least 8 characters, 1 number, 1 upper and 1 lowercase [duplicate]
- JavaScript Regular Expression Email Validation [duplicate]
- Extract image src from a string
- How to prevent invalid characters from being typed into input fields
- How to convert “camelCase” to “Camel Case”?
- javascript regex to extract anchor text and URL from anchor tags
- Example of a regular expression for phone numbers
- Regex for parsing single key: values out of JSON in Javascript
- What’s the correct regex range for javascript’s regexes to match all the non word characters in any script?
- javascript split string by space, but ignore space in quotes (notice not to split by the colon too)
- Mask US phone number string with JavaScript
- Extract keyword from Google search in Javascript
- Regex matching emoticons
- Regex: only alphanumeric but not if this is pure numeric