Let's start with an arbitrary string:
Now modify it replacing the occurrences of a regular expression:
The regexp /([nt])a\b/gi
matches
every word tail composed by a 'n' or a 't' followed
by a 'a'; the String
function member
replace
substitutes the 'a' in those
occurrences with a 'o'.
Now if we have:
And we want to surround all numbers with round
brackets, we will replace every occurrence of
/([\d\.]+)/g
, obtaining: