Show
Regular Expressions 101Please wait while the app is loading...
Regular Expressions 101@regex101DonateSponsorContactBug Reports & FeedbackWikiWhats new? Regex Editor Regex LibraryAccountRegex QuizSettingsLive Help
Save & Share
FlavorNeed help selecting flavor?
Function
Tools
Sponsors Sync your .env files, quickly & securely An explanation of your regex will be automatically generated as you type. Detailed match information will be displayed here automatically. Regular ExpressionNo Match/ / gm Test StringJavaScript Validation with regular expression [21 exercises with solution][An editor is available at the bottom of the page to write and execute the scripts.]1. Write a JavaScript program to test the first character of a string is uppercase or not.
Go to the editor 2. Write a JavaScript program to check a credit card number. Go to the editor 3. Write a pattern that matches e-mail addresses. Go to the editor
Click me to see the solution 4. Write a JavaScript program to search a date within a string. Go to the editor Click me to see the solution 5. Write a JavaScript program that work as a trim function (string) using regular expression. Go to the editor Click me to see the solution 6. Write a JavaScript program to count number of words in string. Go to the
editor Click me to see the solution 7. Write a JavaScript function to check whether a given value is IP value or not. Go to the editor Click me to see the solution 8. Write a JavaScript function to count the number of vowels in a given string. Go
to the editor Click me to see the solution 9. Write a JavaScript function to check whether a given value is an valid url or not. Go to the editor Click me to see the solution 10. Write a JavaScript function to check whether a given value is alpha numeric or not. Go to the editor Click me to see the solution 11. Write a JavaScript function to check whether a given value is time string or not. Go to the editor Click me to see the solution 12. Write a JavaScript function to check whether a given value is US zip code or not. Go to the editor Click me to see the solution 13. Write a JavaScript function to check whether a given value is UK Post Code or not. Go to the editor Click me to see the solution 14. Write a JavaScript function to check whether a given value is Canada Post Code or not. Go to the editor Click me to see the solution 15. Write a JavaScript function to check whether a given value is a social security number or not. Go to the editor Click me to see the solution 16. Write a JavaScript function to check whether a given value is hexadecimal value or not. Go to the editor Click me to see the solution 17. Write a JavaScript function to check whether a given value is hexcolor value or not. Go to the editor Click me to see the solution 18. Write a JavaScript function to check whether a given value represents a domain or not. Go to the editor Click me to see the solution 19. Write a JavaScript function to check whether a given value is html or not.Go to the editor Click me to see the solution 20. Write a JavaScript function to check a given value contains alpha, dash and underscore. Go to the editor Click me to see the solution 21. Write a JavaScript function to print an integer with commas as thousands separators. Go to the editor Test Data : Click me to see the solution More to Come ! * To run the code mouse over on Result panel and click on 'RERUN' button.* Live Demo: See the Pen javascript-common-editor by w3resource (@w3resource) on CodePen. Do not submit any solution of the above exercises at here, if you want to contribute go to the appropriate exercise page. JavaScript: Tips of the DayDestructuring const numbers = [1, 2, 3, 4, 5]; const [y] = numbers; console.log(y); We can unpack values from arrays or properties from objects through destructuring. For example: [a, b] = [1, 2]; The value of a is now 1, and the value of b is now 2. What we actually did in the question, is: [y] = [1, 2, 3, 4, 5]; This means that the value of y is equal to the first value in the array, which is the number 1. When we log y, 1 is returned. Ref: https://bit.ly/323Y0P6 Apa itu regex javascript?Regex adalah singkatan dari Regular Expresion. Regex merupakan sebuah teks (string) yang mendefinisikan sebuah pola pencarian sehingga dapat membantu kita untuk melakukan matching (pencocokan), locate (pencarian), dan manipulasi teks.
Apa yang dimaksud dengan Regular Expression?Regular Expression (RE) adalah sebuah notasi yang dapat digunakan untuk mendeskripsikan pola dari kata yang ingin dicari. Sebagai contoh jika RE yang dibuat adalah ‹‹ nlp ›› maka kata yang akan cocok dengan pola ini hanya kata nlp (sama persis dengan yang ada pada RE).
Method untuk memeriksa apakah sebuah string lolos dari pola regular expression yang diinput?Method test() digunakan untuk memeriksa apakah sebuah string lolos dari pola regular expression yang diinput. Jika lolos, hasilnya true. Jika tidak, hasilnya false.
|