Regular Expressions in JavaScript
Implemeneting regular expressions in Javascript: use str.replace(/[0-9]/gi,"a"); if th estr contains ab09, then the above function will return str=abaa Every regular expression has two properties:-
- g - It specifies that all the matching characters should be replaced. If g is not soecified ponly the first matching charcter will be replaced
- i - The i stands for ignore case
i.e.if the regular experession is /[a-c]/i,"d"
the the str="aAbBcC" will be transforemed to str= "dddddd"
Both the lowercase and upperecase characters will be transformed. If i is not psecified, on.ly the lowercase charcaters will be transformed.
for example, if regularn expression in /[a-c]/, the the string will become "dAdBdC".
Comments
Post a Comment