Created
August 17, 2023 15:35
-
-
Save suhailgupta03/470d592ca3bb015bec61e849a4849496 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| let string = "Recently India celebrated its Independence Day." | |
| // Problem: I want to know if in the above sentence "ebr" occurs togethor or not | |
| // Solution: Use regex to find the pattern | |
| let regex = /ebr/ | |
| // regular expression means a pattern | |
| // pattern that we want to find | |
| // Here the pattern is ebr | |
| // regular expression starts with / and ends with / | |
| // Now we have to find if the pattern occurs in the string or not | |
| let out = regex.test(string) | |
| // test method returns true if the pattern is found in the string | |
| // else it returns false | |
| console.log(out) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment