+ 1

How to validate Regex

I mean to say: for example i have a string ("this is my String") and now i want to do this find the word from the string which contains a capital letter So how can i do it

12th Jul 2018, 1:44 PM
Rohit
Rohit - avatar
2 odpowiedzi
+ 2
Use String.match(regex); To search for a word, use: /\w+/g And, for a word starting with a capital letter, use: /[A-Z]\w+/g So, your required regex would be: "this is my String".match(/[A-Z]\w+/g);
12th Jul 2018, 1:59 PM
777
777 - avatar
+ 1
Thanks Rahul
12th Jul 2018, 7:23 PM
Rohit
Rohit - avatar