"hello _there_".replace(/_(.*?)_/, function(a, b){
return '<div>' + b + '</div>';
})
Oh, or you could also:
"hello _there_".replace(/_(.*?)_/, "<div>$1</div>")
More Related Contents:
- Split a string between special characters [closed]
- Not able to get Regular Expression in javascript
- Find String and extract with next String
- Regex to replace multiple spaces with a single space
- Check for special characters in string
- Template literal inside of the RegEx
- JavaScript regular expressions and sub-matches
- RegEx for match/replacing JavaScript comments (both multiline and inline)
- Restricting character length in a regular expression
- JavaScript regex pattern concatenate with variable
- javascript regular expression to check for IP addresses
- replace all occurrences in a string [duplicate]
- Passing regex modifier options to RegExp object
- How to ignore acute accent in a javascript regex match?
- Regex that can match empty string is breaking the javascript regex engine
- JavaScript replace/regex
- Regular Expression for formatting numbers in JavaScript
- Find all elements whose id begins with a common string
- Regular Expression – Extract subdomain & domain
- Preg_match to regex equivalent expression
- Regular expression to validate US phone numbers? [duplicate]
- JavaScript – string regex backreferences
- Regular Expression for accurate word-count using JavaScript
- JavaScript replace \n with [duplicate]
- What does the forward slash mean within a JavaScript regular expression?
- REGEX: Capture Filename from URL without file extension
- RegEx Ignore Case
- Regex that matches anything except for all whitespace
- How to properly escape characters in regexp
- How to loop all the elements that match the regex?