[EMAIL PROTECTED] wrote:

Here is yet another version:

put replaceText(tText, "\s+", tab) into tText

Now that you've had 3 versions (all of them correct), it might be worth a quick explanation, so you don't go away thinking Regex is a "black art".

RegEx allows the "unix-style" (or C-style, or Perl-style) quoting of special characters, so "\s" means "(space)" - so the two versions of "\s+" and " +" are effectively the same - choose whichever you find easier to read.

Normally in regex,
"*" (asterisk) means "0 or more of the preceding character (or expression)",
while
"+" (plus) means "1 or more of the preceding character (or expression)".


So, "ab+c" would match "abc" or "abbc" or "abbbc" or ..... etc.
and "ab*c" would match all of those, and would also match "ac" ("a" followed by 0 "b"s followed by "c")


This means that " +" means "one or more spaces" while " *" would mean "zero or more spaces" -
EXCEPT that there's a special case of not matching the empty string due to the "*" (that may not be the technically correct way to describe it, but it's the one that I can understand, and is close enough :-)


So in the special case where the *entire* regular expression is qualified by a "*", it acts like "one or more" instead of "zero or more".

There - simple , eh ?  :-) :-)

Seriously, there's a learning curve, but regexes are very powerful; there are lots of tutorials and tools available out on the web (search through Google - I don't have a favourite I'd recommend), including Frederic Rinaldi's rev-based regexbuilder - see http://rinaldicollection.free.fr/

--
Alex Tweedly       http://www.tweedly.net



--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.300 / Virus Database: 266.5.1 - Release Date: 27/02/2005

_______________________________________________
use-revolution mailing list
[email protected]
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to