[Pdx-pm] string function

Ward Cunningham ward at c2.com
Tue Oct 28 18:24:06 CST 2003


I'm having trouble thinking of a good way to compare two strings and 
find out where they differ.

For example, given:

	"abcdewxyz"
	"abcvwxyz"

I would like to find the number of matching characters starting from 
the front or back of the strings. These would be,

	3 match from the front
	4 match from the back

There must be some slick way to do this without looking at each 
individual character in a loop. What am I missing?

Thanks -- Ward

--
Ward Cunningham
503-245-5633 v	mailto:ward at c2.com
503-246-5587 f	http://c2.com




More information about the Pdx-pm-list mailing list