Hi Bob,
You could also use regular expressions.
put LTrim(RTrim(" The cat sat under the mat " )) into tResult
function LTrim pText
get matchtext(pText, "(^[ \t]*(.*))", tFull, tPart)
replace tFull with tPart in pText;
return pText
end function
function RTrim pText
get matchtext(pText, "((.*)[ \t]*$)", tFull, tPart)
replace tFull with tPart in pText;
return pText
end function
(^ means start of word, $ means end of word; . means any
character; .* means any number (0 to many) of any character; [ \t]
means either space or tab (I added tab in case you want to remove
initial tabs as well).
Bob Warren wrote:
Sometimes inexperienced Rev programmers have to ask questions that
make them want to crawl under the table in shame because probably
the answer is idiotically simple. Here is such a question.
If I have a string, say:-
" The cat sat under the mat "
- and I want to trim off the leading and following blanks to give:-
"The cat sat on the mat"
put word 1 to -1 of myVar into mySecondVar
Trimming only one end is slightly harder - in fact, the best way I
can think of is surprisingly complex
put char 1 to -2 of (word 1 to -1 of (t & "=")) -- could have
been any non-space character
put char 2 to -1 of (word 1 to -1 of ("=" & t)) -- could have
been any non-space character
Hopefully someone else will come up with an easier way, and I will
slap my head in annoyance :-)
------------------------------------------------------------------------
--------
Marielle Lange (PhD), Psycholinguist
Alternative emails: [EMAIL PROTECTED], [EMAIL PROTECTED]
Homepage
http://homepages.lexicall.org/mlange/
Easy access to lexical databases http://lexicall.org
Supporting Education Technologists http://
revolution.lexicall.org
_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution