-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
52f23a7
commit 51ef7d6
Showing
28 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
let haStr = "Hazzzzah"; | ||
let haRegex = /Haz{4,}ah/; // Change this line | ||
let result = haRegex.test(haStr); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
let ohStr = "Ohhh no"; | ||
let ohRegex = /Oh{3,6}\sno/; // Change this line | ||
let result = ohRegex.test(ohStr); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
let quoteSample = "The five boxing wizards jump quickly."; | ||
let alphabetRegexV2 = /\wg/; // Change this line | ||
let result = quoteSample.match(alphabetRegexV2).length; | ||
console.log(result) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
let username = "JackOfAllTrades"; | ||
let userCheck = /^[a-z][a-z]+[0-9]*$|[a-z][\d][\d]+$/i; // check whether the username start with 2 letters or start with 1 letter and followed by number. | ||
let result = userCheck.test(username); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
let sample = "Whitespace is important in separating words"; | ||
let countWhiteSpace = /\s/g; // Change this line | ||
let result = sample.match(countWhiteSpace); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
let twinkleStar = "Twinkle, twinkle, little star"; | ||
let starRegex = /twinkle/gi; // Change this line | ||
let result = twinkleStar.match(starRegex); // Change this line |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
let myString = "freeCodeCamp"; | ||
let fccRegex = /freeCodeCamp/i; // Change this line | ||
let result = fccRegex.test(myString); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
let text = "<h1>Winter is coming</h1>"; | ||
let myRegex = /<.*?>/; // Change this line | ||
let result = text.match(myRegex); | ||
console.log(result); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
let quoteSample = "The five boxing wizards jump quickly."; | ||
let alphabetRegexV2 = /\w/gi; // Change this line | ||
let result = quoteSample.match(alphabetRegexV2).length; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
let quoteSample = "The quick brown fox jumps over the lazy dog."; | ||
let alphabetRegex = /[a-z]/gi; // Change this line | ||
let result = quoteSample.match(alphabetRegex); // Change this line |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
let exampleStr = "Let's have fun with regular expressions!"; | ||
let unRegex = /.un/; // Match anything end with un | ||
let result = unRegex.test(exampleStr); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
let quoteSample = "Blueberry 3.141592653s are delicious."; | ||
let myRegex = /[h-s2-6]/ig; // Change this line | ||
let result = quoteSample.match(myRegex); // Change this line | ||
console.log(result); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
let favWord = "favorite"; | ||
let favRegex = /favou?rite/; // Change this line | ||
let result = favRegex.test(favWord); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
let difficultSpelling = "Mississippi"; | ||
let myRegex = /s+/g; // Change this line | ||
let result = difficultSpelling.match(myRegex); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
let repeatNum = "42 42 42"; | ||
let reRegex = /^(\d+)(\s)\1\2\1$/; // Change this line | ||
let result = reRegex.test(repeatNum); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
let timStr = "Timmmmber"; | ||
let timRegex = /Tim{4}ber/; // Change this line | ||
let result = timRegex.test(timStr); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
let extractStr = "Extract the word 'coding' from this string."; | ||
let codingRegex = /coding/; // Change this line | ||
let result = extractStr.match(codingRegex); // Change this line |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
let quoteSample = "The five boxing wizards jump quickly."; | ||
let nonAlphabetRegex = /\W/g; // Change this line | ||
let result = quoteSample.match(nonAlphabetRegex).length; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
let movieName = "2001: A Space Odyssey"; | ||
let noNumRegex = /\D/g; // Change this line | ||
let result = movieName.match(noNumRegex).length; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
let quoteSample = "3 blind mice."; | ||
let myRegex = /[^aeiou0-9]/gi; // Change this line | ||
let result = quoteSample.match(myRegex); // Change this line |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
let sample = "Whitespace is important in separating words"; | ||
let countNonWhiteSpace = /\S/g; // Change this line | ||
let result = sample.match(countNonWhiteSpace); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
let movieName = "2001: A Space Odyssey"; | ||
let numRegex = /\d/g; // Change this line | ||
let result = movieName.match(numRegex).length; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
let quoteSample = "Beware of bugs in the above code; I have only proved it correct, not tried it."; | ||
let vowelRegex = /[aeiou]/gi; // Change this line | ||
let result = quoteSample.match(vowelRegex); // Change this line | ||
console.log(result); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
let myString = "Eleanor Roosevelt"; | ||
let myRegex = /(Franklin|Eleanor).*Roosevelt/; // Change this line | ||
let result = myRegex.test(myString); // Change this line | ||
// After passing the challenge experiment with myString and see how the grouping works |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
let sampleWord = "astronaut"; | ||
let pwRegex = /(?=\w{6,})(?=\D*\d\d)/; // Change this line | ||
let result = pwRegex.test(sampleWord); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
let hello = " Hello, World! "; | ||
let wsRegex = /^(\s+)|(\s+)$/g; // Change this line | ||
let result = hello.replace(wsRegex,""); // Change this line |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
let str = "one two three"; | ||
let fixRegex = /(\w+)\s(\w+)\s(\w+)/; // Change this line | ||
let replaceText = "$3 $2 $1"; // Change this line | ||
let result = str.replace(fixRegex, replaceText); |