Finding the position of a sub string within a strong
loic.grenie at gmail.com
Sun Nov 29 14:12:21 UTC 2009
2009/11/29 Ray Parrish <crp at cmc.net>:
> 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
> 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.
Do you really need to know the position of the string ? Many things
can be done without knowing the position of the substring (substituting
it, for instance).
More information about the ubuntu-users