regEx to remove spaces ?
J. Landman Gay
jacque at hyperactivesw.com
Wed May 17 16:34:04 EDT 2006
jbv wrote:
> Hi list,
>
> Is it possible to use regEx to remove spaces before and
> after quotes, and, if yes, how ?
>
> Example :
> my " beautiful " laundrette
> becomes
> my "beautiful" laundrette
This was harder than I thought it would be. I have something I think
works, but it isn't elegant and others can probably improve on it:
on mouseUp
put fld 1 into tData
put replaceText(tData,"\s{2,}",space) into tData --replace multispaces
replace cr with " **CR** " in tData
repeat for each word w in tData
get w
if it contains quote then
replace quote with empty in it
get quote & word 1 to -1 of it & quote
end if
put it & space after tText
end repeat
delete last char of tText
replace " **CR** " with cr in tText
put tText into fld 2
end mouseUp
--
Jacqueline Landman Gay | jacque at hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
More information about the use-livecode
mailing list