How to validate Regex | Sololearn: Learn to code for FREE!

+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

7/12/2018 1:44:13 PM

Rohit

2 Answers

New Answer

+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);

+1

Thanks Rahul