Javascript Regex: How can I surround all words starting with @ with <b> tags? -


I & lt; B & gt; I want to encompass all the words in a cave starting with ; Which pattern would I use to tag javascript with regex?

  var sample = "sample"; Sample = sample.rele (/ (^ | \ s | -) + @ (\ w +) / g, " b & gt; $ & amp; amp; lt; / b & gt;"); // ^ ^ Assuming that you want @ @ to stay, if not, instead of $ 2, $ & amp;  

$ & amp; Includes matching substrings.

Function use:

  var sample = "@sample"; Sample = sample.rele (/ (| | | | \ | | -) + @ (\ w +) / g, function (ARR) {return "<<"> <+++++++++++++++++++++++++++++++++++++++++++++++++++++++++ It is a good idea to use the function when you want more or better control. You may want to process the currently matched piece. 

>

See more.


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -