- edited to correct for java regex and add B4A example:
B4X:
Dim poMatch As Matcher
Dim piCount As Int
poMatch = Regex.Matcher("\w+(-\w+)*", "There are seven words in this sentence.")
Log(poMatch.GroupCount)
Do While poMatch.Find
Log("Found " & poMatch.Match)
piCount = piCount + 1
Loop
Log(piCount & " words.")
If you need non-standard letters you can be specific and add your "national letters" into the match instead of the default "w" indicator using this syntax: