Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Substitute UC with space UC

Reply
Thread Tools

Substitute UC with space UC

 
 
flamencoman@earthlink.net
Guest
Posts: n/a
 
      03-07-2004
Hi,

Can any one help:

I am trying to replace a strings uppercase letters with a space upper
case letter.

For example, given the string "GeneralPartsList", I want to get the
string " General Parts List".

I tried:

$mystring = "GeneralPartsList";

if($mystring =~ /[A-Z]/)
{
$mystring =~ s/[A-Z]/ [A-Z]/g;
}

but I got an empty string.

Thanks,

Flamencoman
 
Reply With Quote
 
 
 
 
Jürgen Exner
Guest
Posts: n/a
 
      03-07-2004
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> I am trying to replace a strings uppercase letters with a space upper
> case letter.
> For example, given the string "GeneralPartsList", I want to get the
> string " General Parts List".
>
> I tried:
>
> $mystring = "GeneralPartsList";
> if($mystring =~ /[A-Z]/) {
> $mystring =~ s/[A-Z]/ [A-Z]/g;
> }
>
> but I got an empty string.


Really? When I ran you program I got
[A-Z]eneral [A-Z]arts [A-Z]ist
which is what I would have expected.

What about a simple
$_ = "GeneralPartsList";
s/([A-Z])/ $1/g;

jue


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting "not enough disk space error" when there is plenty of disk space Jas Shultz ASP .Net 0 12-03-2003 05:07 PM
Why Python style guide (PEP-8) says 4 space indents instead of 8 space??? 8 space indents ever ok?? Christian Seberino Python 21 10-27-2003 04:20 PM
Re: Why Python style guide (PEP-8) says 4 space indents instead of8 space??? 8 space indents ever ok?? Ian Bicking Python 2 10-24-2003 11:15 AM
Re: Why Python style guide (PEP-8) says 4 space indents instead of8 space??? 8 space indents ever ok?? Ian Bicking Python 2 10-23-2003 07:07 AM
Stack space, global space, heap space Shuo Xiang C Programming 10 07-11-2003 07:30 PM



Advertisments