From REALbasicWiki
| Overall article skill
|  ✭
|
|
|
| Available for
|
|
| Some string extensions that nobody could do without !
|
|
|
| License
| Open source. Use it for any commercial or non-commercial purpose.
|
| Download
| none
|
| Developer's site
| none
|
There are some string functions that I just cannot do without and here they are. Do not expect anything optimized, it just works ! But if you can do better, feel free to share this with us !
//In a MODULE
Function BeginsWith( extends s as string, searchString as string, CaseSensitive as boolean = false ) as boolean
//Determine if the string begins with search string
dim t as string
dim a as integer
if not CaseSensitive then a=1
t = Left(s, len(SearchString))
return (StrComp(t, searchString, a)=0)
End function
Function StringAfter( extends s as string, beginningString as string ) as string
//Return the string after the past string
dim a as integer
a = Instr(s, beginningString)
return Mid(s, len(beginningString) + a)
End function
Function StringBefore( extends s as string, beforeString as string ) as string
return NthField(s, beforeString, 1)
End function
Function StringBetween( extends src as string, startTag as string, endTag as string, trimResult as boolean = true ) as string
//Take the string between the first occurrence of startTag and the endTag
dim s as string
s = src.StringAfter( startTag )
s = s.StringBefore( endTag )
if trimResult then
return Trim( s )
else
return s
end if
End function