Author: Michael Madigan
Posted: 2005-08-01 at 14:48:27
I can't think of anything better than that. However,
? fulltrim(",@#$a&&bc$%^") causes an error
--- Malcolm Greene <profox@bdurham.com> wrote:
> Any suggestions on how I can quickly alltrim all
> non-alpha chars from a
> string via either a clever VFP technique, FoxTools
> FLL function, or
> Win32 API call?
>
> My current approach below. But certainly there must
> be a more efficient
> way?
>
> NOTE: I want to preserve embedded non-alpha chars. I
> just want to remove
> leading and trailing non-alpha chars.
>
> <code>
>
> function fulltrim( pcStr )
> for lnChar = 1 to len( pcStr )
> if isalpha( substr( pcStr, lnChar, 1 ) )
> exit
> endif
> endfor
> pcStr = substr( pcStr, lnChar )
>
> for lnChar = len( pcStr ) to 1 step -1
> if isalpha( substr( pcStr, lnChar, 1 ) )
> exit
> endif
> endfor
> pcStr = left( pcStr, lnChar )
>
> return pcStr
> endfunc
>
> </code>
>
> Thanks,
> Malcolm
>
>
> _______________________________________________
> Post Messages to: ProFox@leafe.com
> Subscription Maintenance:
> http://leafe.com/mailman/listinfo/profox
> OT-free version of this list:
> http://leafe.com/mailman/listinfo/profoxtech
> ** All postings, unless explicitly stated otherwise,
> are the opinions of the author, and do not
> constitute legal or medical advice. This statement
> is added to the messages for those lawyers who are
> too stupid to see the obvious.
>