Finding the position of a sub string within a strong

Ray Parrish crp at cmc.net
Sun Nov 29 14:09:08 UTC 2009


Hello,

I am starting to get a grasp on what can be done with regular 
expressions, and I now know how to extract a sub string from within 
another string if I know it's offset, and length.

The thing I haven't discovered during all of this reading is a way to 
return the position of a substring within another string.

How would I return the position of the sub string "zat" in the string 
"abczat1256"?

I know how to get the length of a string now, but not how to search 
within it yet. I have thought of a cludge which involves stripping 
character at a time from the front of the string into an array, but why 
re-invent the wheel when I'm sure there is already a simpler way to do this.

Thanks for any help you can be.

Later, Ray Parrish

-- 
The Future of Technology.
http://www.rayslinks.com/The%20Future%20of%20Technology.html
Ray's Links, a variety of links to usefull things, and articles by Ray.
http://www.rayslinks.com
Writings of "The" Schizophrenic, what it's like to be a schizo, and other
things, including my poetry.
http://www.writingsoftheschizophrenic.com






More information about the ubuntu-users mailing list