Java Reference
In-Depth Information
Now imagine that you change that code, so that you create the RegExp object like this:
var myRegExp = new RegExp(“(\b\w+\b) \1”);
Why would this not work, and how could you rectify the problem?
2.
Write a regular expression that fi nds all of the occurrences of the word “a” in the following sen-
tence and replaces them with “the”:
“a dog walked in off a street and ordered a fi nest beer”
The sentence should become:
“the dog walked in off the street and ordered the fi nest beer”
3.
Imagine you have a web site with a message board. Write a regular expression that would
remove barred words. (You can make up your own words!)
Search WWH ::




Custom Search