-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Akin C edited this page Jan 1, 2020
·
18 revisions
This repository is part of a larger project!
With the help of RegExp constructor, regular expressions should be possible to use.
Two methods should be of interest here:
🔖 It should be clarified that match is a String method and not a RegExp.
The big difference between the two methods should be that test prints a Boolean value to check for a match, while match should print an array or null if it is used.
An example follows for both cases:
var myString = "Hello World!";
var myRegExp = new RegExp("Hello");
//---test---//
// Searches for a match with the word "Hello" within "Hello World"
var result = myRegExp.test(myString);
// Outputs: true
console.log(result);
//---match---//
// Searches for a match with the word "Hello" within "Hello World"
result = myString.match(myRegExp);
// Outputs: ["Hello", index: 0, input: "Hello World!", groups: undefined]
console.log(result);STILL IN WORK!
This knowledge was gained:
- Effective JavaScript "68 Specific Ways to Harness the Power of JavaScript" by David Herman
- Learn Regular Expressions (Regex) - Crash Course for Beginners by freeCodeCamp.org
- A guide to JavaScript Regular Expressions by Flavio Copes
- RegExp(GER) & RegExp(ENG) by MDN
Sources:
- Servomotor on wikipedia
- console.table by MDN