Substitute UC with space UC

Discussion in 'Perl' started by flamencoman@earthlink.net, Mar 7, 2004.

  1. Guest

    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
    , Mar 7, 2004
    #1
    1. Advertising

  2. 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
    Jürgen Exner, Mar 7, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jas Shultz
    Replies:
    0
    Views:
    936
    Jas Shultz
    Dec 3, 2003
  2. Shuo Xiang

    Stack space, global space, heap space

    Shuo Xiang, Jul 9, 2003, in forum: C Programming
    Replies:
    10
    Views:
    2,864
    Bryan Bullard
    Jul 11, 2003
  3. Christian Seberino
    Replies:
    21
    Views:
    1,622
    Stephen Horne
    Oct 27, 2003
  4. Ian Bicking
    Replies:
    2
    Views:
    979
    Steve Lamb
    Oct 23, 2003
  5. Ian Bicking
    Replies:
    2
    Views:
    706
    Michael Hudson
    Oct 24, 2003
Loading...

Share This Page