[Tutor] regular expressions query

mhysnm1964 at gmail.com mhysnm1964 at gmail.com
Thu May 23 20:15:45 EDT 2019


All,

 

Below I am just providing the example of what I want to achieve, not the
original strings that I will be using the regular expression against.

 

The original strings could have:

 

"Hello world"

"hello  World everyone"

"hello everyone"

"hello   world and friends"

 

I have a string which is "hello world" which I want to identify by using
regular expression how many times:

*	"hello" occurs on its own.
*	"Hello world" occurs in the list of strings regardless of the number
of white spaces.

 

Splitting the string into an array ['hello', 'world'] and then re-joining it
together and using a loop to move through the strings does not provide the
information I want. So I was wondering if this is possible via regular
expressions matching?

 

Modifying the original string is one option. But I was wondering if this
could be done?



More information about the Tutor mailing list