Saturday 1 November 2014

Match any word character \w

\w match a word character : [a-zA-Z_0-9].

For Example, the regular expression '\w+[\s+.]' matches the words in given string.

Sample Output
Enter Regular Expression
\w+[\s+.]
Enter the string
Hello How are you.
I found the text Hello  starting at index 0 Ending at index 6
I found the text How  starting at index 6 Ending at index 10
I found the text are  starting at index 10 Ending at index 14
I found the text you. starting at index 14 Ending at index 18

Enter the string
I am fine
I found the text I  starting at index 0 Ending at index 2
I found the text am  starting at index 2 Ending at index 5

Note
Use this program to run above sample


Prevoius                                                 Next                                                 Home

No comments:

Post a Comment