470,613 Members | 2,311 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,613 developers. It's quick & easy.

Substitute UC with space UC

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
Jul 19 '05 #1
2 2670
fl*********@earthlink.net 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
Jul 19 '05 #2
On Sun, 07 Mar 2004 20:02:09 GMT, "Jürgen Exner"
<ju******@hotmail.com> wrote:
fl*********@earthlink.net 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


Jue,

This works great thanks! I was getting an empty string because I left
off the tilde in my actual code, so $mystring was not bound to the
expression.

Thanks,

Flamencoman
Jul 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by francescomoi | last post: by
3 posts views Thread by Robert Anderson | last post: by
35 posts views Thread by Felix Kater | last post: by
5 posts views Thread by Steve Richter | last post: by
4 posts views Thread by vijay.rajamanickam | last post: by
1 post views Thread by Rocky Zhou | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.