I am new to REGEX, I am trying to get only the words "She" and "Shell", not the ashes with this program (Groovy). I have been working on it for some time.
saying = 'She wishes for Shells not ashes'
println saying
def pattern = ~/\bShe*\b/
def matcher = pattern.matcher(saying)
def count = matcher.getCount()
println "Matches = ${count}"
for (i in 0..<count) {
print matcher[i] + " "
}
Conclusion: She wants Shells not ashes Matches = 1 She
REGEX does not work like Windows CMD, for example, dir W * to specify a folder or files starts with W. What did I do wrong?
Thank you very much if you answer this question.
source
share