Hi,
The normal behavior
'abc' howManyMatch: 'abd' --> 2.
I got suprized the way Blanks and new lines are handled.
'\**' withCRs howManyMatch: '\\**' withCRs. --> 2 instead of 1
'ab\ **' withCRs howManyMatch: 'ab\\**' withCRs. --> 4 instead of 3
'\ **' withCRs howManyMatch: '\\**' withCRs. --> 3 instead of 1
'ab\ **' withCRs howManyMatch: 'ab\\**' withCRs. --> 5 instead of 3
The behavior is the same in both Pharo 3 and Pharo 4.
Reading the code of does not help me understand why it's this way
String>>howManyMatch: string
"Count the number of characters that match up in self and aString."
| count shorterLength |
count := 0.
shorterLength := self size min: string size.
1 to: shorterLength do: [:index |
(self at: index) = (string at: index )
ifTrue: [ count := count + 1 ]].
^ count
Noury
Afin de contribuer au respect de l'environnement,
merci de n'imprimer ce courriel qu'en cas de necessite
Please consider the environment before you print