()
.
If you want to find either Penguin
or Pumpkin
in a string, you can use the following Regular Expression: /P(engu|umpk)in/g
Then check whether the desired string groups are in the test string by using the test()
method.
```js
let testStr = "Pumpkin";
let testRegex = /P(engu|umpk)in/;
testRegex.test(testStr);
// Returns true
```
Franklin Roosevelt
or Eleanor Roosevelt
in a case sensitive manner and it should make concessions for middle names.
Then fix the code so that the regex that you have created is checked against myString
and either true
or false
is returned depending on whether the regex matches.
myRegex
should return true
for the string Franklin D. Roosevelt
testString: myRegex.lastIndex = 0; assert(myRegex.test('Franklin D. Roosevelt'));
- text: Your regex myRegex
should return true
for the string Eleanor Roosevelt
testString: myRegex.lastIndex = 0; assert(myRegex.test('Eleanor Roosevelt'));
- text: Your regex myRegex
should return false
for the string Franklin Rosevelt
testString: myRegex.lastIndex = 0; assert(!myRegex.test('Franklin Rosevelt'));
- text: Your regex myRegex
should return false
for the string Frank Roosevelt
testString: myRegex.lastIndex = 0; assert(!myRegex.test('Frank Roosevelt'));
- text: You should use .test()
to test the regex.
testString: assert(code.match(/myRegex.test\(\s*myString\s*\)/));
- text: Your result should return true
.
testString: assert(result === true);
```