I've to Thank Charles once again for the latest post which solved the
puzzle.

Jeff gave the solution as s/ ( +)/' ' x length($1)/g;
which is what I want but did not work as intended because of the missing e
at the end of the expression
but after looking at Charles example s/(\s\s+)/' ' x (length($1) -
1)/ge;
I then changed Jeff's exp. to include an e to the end of the exp and it
works perfectly.

Therefore the final tested expression which I want is as follows:-
$a =~s/ ( +)/' ' x length($1)/ge;

Charles solution is very good but unfortunately I do not wish to substitute
\n.

Problem solved!
Thank You Everybody

--- end of msg ----

----- Original Message -----
From: "Charles K. Clarkson" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, November 28, 2001 4:40 AM
Subject: Re: [PBML] help needed on substitution regex


> "Leon" <[EMAIL PROTECTED]> asked:
>
> : I have 2 things which I need members help.
> :
> : (Q1)    How to put these three substitutions into one single
> : substitution regex.
> : $a =~s/</lt/;
> : $a =~s/>/gt/;
> : $a =~s/\\n/<br>/;
>
>     It would be more efficient to leave them as is. You could
> use 'for' to make the regexes easier to maintain though:
>
> for ($a) {
>     s/</lt/;
>     s/>/gt/;
>     s/\\n/<br>/;
> }
>
> : (Q2)    How to do the following :-
> :            If there are 2 spaces, I wish to convert it into 1 &nbsp like
> : this =>&nbsp
> :            3 spaces into 2 &nbsp like this => &nbsp&nbsp
> :            4 spaces into 3 &nbsp like this => &nbsp&nbsp&nbsp
> :            and so on.....
> :
> : I can only think of this undermentioned example but does not know
> : how to fit it into the above Q2 :-
> : $a =~s/ /&nbsp/;
>
>    As Bompa points out &nbsp has a semi-colon at the end (&nbsp;).
> There is likely a more elegant way to do this, but . . .
>
>         s/(\s\s+)/'&nbsp;' x (length($1) - 1)/ge;
>
>
> HTH,
> Charles K. Clarkson
> Clarkson Energy Homes, Inc.
>
>
> My forehead has a hand-shaped imprint on it.
>
>
>
>
>
>
> ------------------------ Yahoo! Groups Sponsor ---------------------~-->
> Universal Inkjet Refill Kit $29.95
> Refill any ink cartridge for less!
> Includes black and color ink.
> http://us.click.yahoo.com/4bQK.B/MkNDAA/ySSFAA/ndFolB/TM
> ---------------------------------------------------------------------~->
>
> Unsubscribing info is here:
http://help.yahoo.com/help/us/groups/groups-32.html
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to