regEx to remove spaces ?

classic Classic list List threaded Threaded
18 messages Options
Reply | Threaded
Open this post in threaded view
|

regEx to remove spaces ?

jbv-2
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

Thanks,
JB

_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: regEx to remove spaces ?

masmit
If you don't mind it not being regex, then

set the itemDelimiter to quote
repeat for each item i in myString
   put word 1 to -1 of i & quote after newString
end repeat
if char -1 of myString is not quote then delete char -1 of newString


should work.

Best,

Mark Smith

On 17 May 2006, at 10:45, 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
>
> Thanks,
> JB
>
> _______________________________________________
> use-revolution mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your  
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution

_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: regEx to remove spaces ?

xtalkprogrammer
In reply to this post by jbv-2
Hi JB,

Again, no regex. I looked into regex, but I can't find how to replace  
quoted strings without knowing the whole string in advance. It would  
be great if someone came up with a regex solution for this. In the  
mean time, this function seems to do the job quite nicely:

function decentQuotes theStr
   set the itemDel to space
   repeat for each word myWord in theStr
     if number of items of myWord > 1
     then put quote & word 1 to -1 of (char 2 to -2 of myWord) & ¬
     quote & space after myNewStr else put myWord & space after myNewStr
   end repeat
   return char 1 to -2 of myNewStr
end decentQuotes

Note that it assumes that strings are always surrounded by pairs of  
quotes. Grammar errors are not taken care of.

Best,

Mark

--

Economy-x-Talk
Consultancy and Software Engineering
http://economy-x-talk.com
http://www.salery.biz

Salery is the easiest way to get your own web store on-line: http://
www.salery.biz/salery.html



Op 17-mei-2006, om 11:45 heeft jbv het volgende geschreven:

> 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
>
> Thanks,
> JB

_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Kind regards,

Drs. Mark Schonewille

Economy-x-Talk Consultancy and Software Engineering
Homepage: http://economy-x-talk.com
Twitter: http://twitter.com/xtalkprogrammer
Facebook: http://facebook.com/LiveCode.Beginner
KvK: 50277553
Reply | Threaded
Open this post in threaded view
|

Re: regEx to remove spaces ?

Alex Tweedly
In reply to this post by jbv-2
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
>
>  
>
I'm not entirely clear on what you're asking for ...
given the description  (remove spaces before and after quotes), I'd have
expected that

    my " beautiful " laundrette
becomes
    my"beautiful"laundrette

Do you actually want to
   remove spaces after the "opening" quote
   remove spaces before the "closing" quote
of any quoted sub-string ?

What if there are mismatched quotes ?  
   (Does that matter, or can you exclude the possibility ?)

It should be doable with regex - but will probably be faster without it ....

something like  (the value is already in variable t)

put empty into tNew
set the itemdel to quote
put True into outside
repeat for each item w in t
  if outside then
    put false into outside
    put w & quote after tNew
  else
   put true into outside
   put word 1 to -1 of w & quote after tNew
  end if
end repeat
put tNew after msg
if char -1 of t = quote then
  delete char -1 of tNew
end if





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



--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.392 / Virus Database: 268.5.6/340 - Release Date: 15/05/2006

_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: regEx to remove spaces ?

Alex Tweedly
In reply to this post by xtalkprogrammer
Mark Schonewille wrote:

> Hi JB,
>
> Again, no regex. I looked into regex, but I can't find how to replace  
> quoted strings without knowing the whole string in advance. It would  
> be great if someone came up with a regex solution for this. In the  
> mean time, this function seems to do the job quite nicely:
>
> function decentQuotes theStr
>   set the itemDel to space
>   repeat for each word myWord in theStr
>     if number of items of myWord > 1
>     then put quote & word 1 to -1 of (char 2 to -2 of myWord) & ¬
>     quote & space after myNewStr else put myWord & space after myNewStr
>   end repeat
>   return char 1 to -2 of myNewStr
> end decentQuotes
>
> Note that it assumes that strings are always surrounded by pairs of  
> quotes. Grammar errors are not taken care of.
>
I think it also assumes the input string is on a single line, since cr
is a word delimiter, so input like

> first line
> second line


becomes

> first line second line


And input like ("."s to indicate where the spaces are ....)

> first ".line..
> ..second.." line


get badly mangled into

> first "line" second "lin"




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



--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.392 / Virus Database: 268.5.6/340 - Release Date: 15/05/2006

_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: regEx to remove spaces ?

Jim Ault
In reply to this post by jbv-2
On 5/17/06 2:45 AM, "jbv" <[hidden email]> wrote:

> 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

There are a few ways to use RegEx, depending on the exact situations you
face.  Your question targets two strings that are identical, occuring at
opposite ends of a word or phrase.

[A Rev solution follows at the bottom.]

So
will there be more than one quoted passage per line
will there be a return in the middle of the quote (or more than one cr)
will the white space next to the quote always be a space
   eg ( " beautiful " launderette,  but knobs are " chinsy ". )
thus a period follows the last quote, not a space.

RegEx has simple pattern replacement, plus and/or logic, plus lookForward,
lookBackwards.  Thus it has very sophisticated algorithms possible, so it is
important that you be very specific about the task.

So, are all the possible strings (with commas and periods)?
s"sWORDs"s
s"sWORDs",
s"sWORDs".
,"sWORDs"s
s" WORDs"s
s"sWORDs"s

which means we are looking for 4 strings
(s"s)(,"s)(s".)(s",)
on the same line defined by CR (or LFCR which is a Windows end of line
marker?)

In RegEx, one expression can contain the (this|that|other) format, allowing
alternate hits to be considered.  Also, RegEx can find the first occurance,
then scan to find the next either forward to the end, or back toward the
front of the string.  As you see, it can get more complicated than you ever
wanted.

One Rev technique that could get you where you want to go is...
--handles multiple instances, spanning across lines
--but this ver does not look for trailing comma or period.

--text in------------------------------------------
The " dream " continues
and will not " die ", even a " slow,
mangled " death
and lives for the ages.
IBID 26
-------------------------------------
on mouseDoubleUp
  put fld 1 into txt
  replace cr with "MMMM" in txt  --protect line wraps
  replace (" "&quote&" ") with (" "&cr&" ") in txt
  repeat with x = the number of lines in txt down to 2
    if char 1  of line x of txt is space and char 1 of line x-1 of txt is
space then
      put word 1 to -1 of line x-1 of txt into line x-1 of txt
    end if
  end repeat
  replace cr with quote in txt
  replace "MMMM" with cr in txt
  put txt into fld 2
end mouseDoubleUp
--text out-------------------------------------------------
The "dream" continues
and will not "die" even a "slow,
mangled" death
and lives for the ages.
IBID 26
------------------------------------------------------

More than you had imagined, I am sure.

Jim Ault
Las Vegas



_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: regEx to remove spaces ?

J. Landman Gay
In reply to this post by jbv-2
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         |     [hidden email]
HyperActive Software           |     http://www.hyperactivesw.com
_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: regEx to remove spaces ?

xtalkprogrammer
In reply to this post by Alex Tweedly
Hi Alex,

You're right about the additional assumptions, although one might  
call the function within another repeat loop for each line, if each  
pair of quotes is in one single line. As other solutions have shown,  
one may also replace the return with a unique string before calling  
this function.

As to the spaces, one will not want to apply any of the available  
solutions, if the number of characters of the new string needs to be  
equal to the number of characters of the old string and normally you  
don't want to have 2 spaces subsequently. It is possible, though, to  
apply another correction, by adding spaces as necessary. Also,  
starting and trailing spaces of the entire text would have to be  
added. All other spaces are included in the new string.

Best,

Mark

--

Economy-x-Talk
Consultancy and Software Engineering
http://economy-x-talk.com
http://www.salery.biz

Salery is the easiest way to get your own web store on-line: http://
www.salery.biz/salery.html



Op 17-mei-2006, om 17:47 heeft Alex Tweedly het volgende geschreven:

> Mark Schonewille wrote:
>
>> Again, no regex. I looked into regex, but I can't find how to  
>> replace  quoted strings without knowing the whole string in  
>> advance. It would  be great if someone came up with a regex  
>> solution for this. In the  mean time, this function seems to do  
>> the job quite nicely:
>>
>> function decentQuotes theStr
>>   set the itemDel to space
>>   repeat for each word myWord in theStr
>>     if number of items of myWord > 1
>>     then put quote & word 1 to -1 of (char 2 to -2 of myWord) & ¬
>>     quote & space after myNewStr else put myWord & space after  
>> myNewStr
>>   end repeat
>>   return char 1 to -2 of myNewStr
>> end decentQuotes
>>
>>
> I think it also assumes the input string is on a single line, since  
> cr is a word delimiter, so input like
>
>> first line
>> second line
>
>
> becomes
>
>> first line second line
>
>
> And input like ("."s to indicate where the spaces are ....)
>
>> first ".line..
>> ..second.." line
>
>
> get badly mangled into
>
>> first "line" second "lin"
>

_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Kind regards,

Drs. Mark Schonewille

Economy-x-Talk Consultancy and Software Engineering
Homepage: http://economy-x-talk.com
Twitter: http://twitter.com/xtalkprogrammer
Facebook: http://facebook.com/LiveCode.Beginner
KvK: 50277553
Reply | Threaded
Open this post in threaded view
|

Re: regEx to remove spaces ?

jbv-2
many thanks to all list members who responded to my question.

actually I had already cooked my own script (see below - not
really elegant, but efficient & fast enough for what I need to do).
I was just wondering if it could be done in a simpler way with
a regEx...

Best,
JB


  put "" into myL
  put 0 into mySkip
  put 0 into x
  repeat forever
    get offset(quote,myTXT,mySkip)
    if it=0 then
      exit repeat
    end if

    add it to mySkip
    put mySkip & "," after myL
    add 1 to x
    if x=2 then
      put cr into last char of myL
    end if
  end repeat

  repeat with j=number of lines of myL down to 1
    put line j of myL into a
    get (item 2 of a)-1
    if char it of myTXT=" " then
      delete char it of myTXT
    end if
    get 1+(item 1 of a)
    if char it of myTXT=" " then
      delete char it of myST
    end if
  end repeat

_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Identifying the end of a file transfer

Richard Miller-5
In reply to this post by xtalkprogrammer
I've got one stack sending a file out to server, and a separate stack  
(on a separate machine) scanning the server for the availability of  
that file. When it sees it, it needs to retrieve it from the server.

Problem is, this second stack is seeing the availability of the file  
BEFORE it has completely transferred onto the server. If it starts  
retrieving it when it first sees it, well... the result isn't good.

Is there any simple way for the second stack to know the file  
transfer is complete before it starts accessing this file? I realize  
I could have the first stack send a small "flag" file out to the  
server after the original file was transferred, and the second stack  
could wait until it sees that flag... but I'm wondering if there  
isn't some easier way.

Thanks.
Richard Miller
Imprinter Technologies
_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: Identifying the end of a file transfer

Ton Kuypers-2
Check the size of the file, check it again in 2 seconds. If the size  
is the same, the file should be on the server...
But your "flag-file" should do just as easy...

Warm regards,

Ton Kuypers
Digital Media Partners bvba
Tel. +32 (0)477 / 739 530
Fax +32 (0)14 / 71 03 04
http://www.dmp-int.com



On 18-mei-06, at 15:20, Richard Miller wrote:

> I've got one stack sending a file out to server, and a separate  
> stack (on a separate machine) scanning the server for the  
> availability of that file. When it sees it, it needs to retrieve it  
> from the server.
>
> Problem is, this second stack is seeing the availability of the  
> file BEFORE it has completely transferred onto the server. If it  
> starts retrieving it when it first sees it, well... the result  
> isn't good.
>
> Is there any simple way for the second stack to know the file  
> transfer is complete before it starts accessing this file? I  
> realize I could have the first stack send a small "flag" file out  
> to the server after the original file was transferred, and the  
> second stack could wait until it sees that flag... but I'm  
> wondering if there isn't some easier way.
>
> Thanks.
> Richard Miller
> Imprinter Technologies
> _______________________________________________
> use-revolution mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your  
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
>

_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: Identifying the end of a file transfer

Sarah Reichelt-2
In reply to this post by Richard Miller-5
On 5/18/06, Richard Miller <[hidden email]> wrote:

> I've got one stack sending a file out to server, and a separate stack
> (on a separate machine) scanning the server for the availability of
> that file. When it sees it, it needs to retrieve it from the server.
>
> Problem is, this second stack is seeing the availability of the file
> BEFORE it has completely transferred onto the server. If it starts
> retrieving it when it first sees it, well... the result isn't good.
>
> Is there any simple way for the second stack to know the file
> transfer is complete before it starts accessing this file? I realize
> I could have the first stack send a small "flag" file out to the
> server after the original file was transferred, and the second stack
> could wait until it sees that flag... but I'm wondering if there
> isn't some easier way.

Upload the file with a temporary name, then re-name it once it has
completely uploaded. The rename should be virtually instant.

Cheers,
Sarah
_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: Identifying the end of a file transfer

Richard Miller-5
Good idea. Thanks.
Richard



On May 18, 2006, at 4:40 PM, Sarah Reichelt wrote:

> On 5/18/06, Richard Miller <[hidden email]> wrote:
>> I've got one stack sending a file out to server, and a separate stack
>> (on a separate machine) scanning the server for the availability of
>> that file. When it sees it, it needs to retrieve it from the server.
>>
>> Problem is, this second stack is seeing the availability of the file
>> BEFORE it has completely transferred onto the server. If it starts
>> retrieving it when it first sees it, well... the result isn't good.
>>
>> Is there any simple way for the second stack to know the file
>> transfer is complete before it starts accessing this file? I realize
>> I could have the first stack send a small "flag" file out to the
>> server after the original file was transferred, and the second stack
>> could wait until it sees that flag... but I'm wondering if there
>> isn't some easier way.
>
> Upload the file with a temporary name, then re-name it once it has
> completely uploaded. The rename should be virtually instant.
>
> Cheers,
> Sarah
> _______________________________________________
> use-revolution mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your  
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution

_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: regEx to remove spaces ?

Sivakatirswami
In reply to this post by jbv-2

On May 16, 2006, at 11:45 PM, 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

I'm curious what mandates regEx?

if the means is not an issue in reaching the goal ,  doesn't  
"replace" work for you?

This is obvious, but for the record:

function wipeQuotedSpaces tText
        put (quote & " ") into tOpenSpace
        put ( " " & quote) into tCloseSpace
        replace tOpenSpace with quote in tText
        replace tCloseSpace with quote in tText
        return tText
end wipeQuotedSpaces

>
> Thanks,
> JB

_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: regEx to remove spaces ?

John Craig-2
In reply to this post by jbv-2
Apologies - sent the wrong snippet earlier. The correct version (very

similar) is;

Here's a small snippet that will replace spaces within quotes using
regex's.  Just put your data into tString and the new data is put into
tResult.

put tString into tResult
repeat while matchText(tString, "([" & quote & "][^" & quote & "]+[" & quote & "])", tMatch)
 put replaceText(tMatch, " ", "") into tReplacement
 put replaceText(tResult, tMatch, tReplacement) into tResult
 put replaceText(tString, tMatch, "") into tString
end repeat


Hope this is of use, JB.

JC






_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: regEx to remove spaces ?

jbv-2
In reply to this post by Sivakatirswami
Hi,

thanks for the response, but I don't think it would work...

let's go back to my example :
    my " beautiful " laundrette

if you replace tOpenSpace first, then you get :
    my "beautiful "laundrette

and then if you replace tCloseSpace, you get
    my"beautiful"laundrette

Thanks anyway,
JB

>
>
> I'm curious what mandates regEx?
>
> if the means is not an issue in reaching the goal ,  doesn't
> "replace" work for you?
>
> This is obvious, but for the record:
>
> function wipeQuotedSpaces tText
>         put (quote & " ") into tOpenSpace
>         put ( " " & quote) into tCloseSpace
>         replace tOpenSpace with quote in tText
>         replace tCloseSpace with quote in tText
>         return tText
> end wipeQuotedSpaces
>
> >
> > Thanks,
> > JB

_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: regEx to remove spaces ?

Martin Baxter-3
# How about:

put "my " & quote & " beautiful " & quote & " laundrette" into srctext
put "<" into repchar
put 0 into oldoff
put 1 into toff
repeat while toff > 0
  put offset(quote,srctext,oldoff) into toff
  if toff > 0 then
  put repchar into char oldoff + toff of srctext
  add toff to oldoff
   if repchar ="<" then
    put ">" into repchar
   else
    put "<" into repchar
   end if
  end if
end repeat
put replacetext(srctext,"<[ ]+",quote) into srctext
put replacetext(srctext,"[ ]+>",quote) into srctext
put srctext

-- output: my "beautiful" laundrette

# Not a very pretty or robust script but it worked on your test data.

I don't know if there will only ever be one consecutive superfluous
space but I had it clean up multiple spaces anyway.

There is a big assumption in this that opening and closing quotes are
always balanced. If this is not the case, this procedure will give bad
results.

Also if the characters "<" and ">" might occur in the data, different
substitution characters should be used. These are OK on this example.

Martin Baxter

jbv wrote:

> Hi,
>
> thanks for the response, but I don't think it would work...
>
> let's go back to my example :
>     my " beautiful " laundrette
>
> if you replace tOpenSpace first, then you get :
>     my "beautiful "laundrette
>
> and then if you replace tCloseSpace, you get
>     my"beautiful"laundrette
>
> Thanks anyway,
> JB
>
>>
>> I'm curious what mandates regEx?
>>
>> if the means is not an issue in reaching the goal ,  doesn't
>> "replace" work for you?
>>
>> This is obvious, but for the record:
>>
>> function wipeQuotedSpaces tText
>>         put (quote & " ") into tOpenSpace
>>         put ( " " & quote) into tCloseSpace
>>         replace tOpenSpace with quote in tText
>>         replace tCloseSpace with quote in tText
>>         return tText
>> end wipeQuotedSpaces
>>
>>> Thanks,
>>> JB
>


_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: regEx to remove spaces ?

Dar Scott
In reply to this post by jbv-2

On May 17, 2006, at 3:45 AM, jbv wrote:

> 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

(?x)
(?<=")  \ +  (?= [^"]* "  (?>(?:[^"]*"){2})* [^"]* \z)
|
         \ +  (?= "        (?>(?:[^"]*"){2})* [^"]* \z)


on mouseUp
   put replaceText(field "In",field "regex","") into field "Out"
end mouseUp

This is slow for long strings.  The regex experts might have some  
ideas on how to speed that up.  For every match it has to check the  
rest of the string to make sure the quotes pair up.  Ow.

This uses assertions to get around the whole-match nature of  
replaceText().

The \ + matches the spaces to be removed.  The (?x) allows me to use  
whitespace in the regex.

In the lines of the regex the part before the space matching is the  
lookbehind assertion and the part after is the lookahead assertion.

To create the regex, I'd use format() which allows a special \"  
notation for literals in the first parameter, but the usual '& quote  
&' method will also work.

This pairs quotes from the right, so if the quotes are not paired,  
this will goof up at the start of the string.

Dar Scott

_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution