Cedric Villat wrote:

> I want to remove all periods ( . ) that do not appear between 2 numbers. For 
> instance, I would want to keep this period:
> 
> 5.5
> 
> But not these:
> 
> www.domain.com
> 
> I want the periods to be replaces with a space in the second example. 
> Anyone?

I don't think there's any sane way to do this with a single POSIX regexp 
(I think I could do it in one with a Perl RE, but it would be ugly); I'd 
love to be proved wrong though. .

bar=rereplace(foo, "([^0-9])\.([^0-9])", "\1 \2", "ALL")

would be safe, but would miss (say) "a.5"; you don't say what you want 
to do with multiple periods either...

My inclination would be to do it in three bites: replace the periods you 
*want* to keep with a character guaranteed not to be in your string, say 
SOH, (you can always do a zero'th pass to strip such out), replace all 
remaining periods with spaces and finally restore the periods you want:

temp=rereplace(foo, "([0-9])\.([0-9])", "\1#chr(1)#\2", "ALL");
temp=replace(temp, ".", " ", "ALL");
bar=replace(temp, chr(1), ".", "ALL");

It's not what you asked for, but it *is* only one regexp :)

-- 
Pete Jordan

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:195719
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to