Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re: Splitting on non-initial uppercase without split

by edan (Curate)
on Jan 26, 2005 at 10:46 UTC ( #425168=note: print w/replies, xml ) Need Help??

in reply to Splitting on non-initial uppercase without split

This works, but I have the distinct feeling there is a more straightforward way to do it...

$s =~ s/(?<!^)(?=[A-Z])/ /g;

Replies are listed 'Best First'.
Re^2: Splitting on non-initial uppercamse without split
by ambrus (Abbot) on Jan 26, 2005 at 20:09 UTC

    What about this:

    $s =~ s/\B(?=[[:upper:]])/ /g;
    or this
    $s =~ s/\B([[:upper:]])/ $1/g;
Re^2: Splitting on non-initial uppercase without split
by tphyahoo (Vicar) on Jan 26, 2005 at 12:03 UTC
    How about:
    $s =~ s/([a-z])([A-Z])/$1 $2/ig;
      I guess you would want to make your regex case sensitive:
      $s =~ s/([a-z])([A-Z])/$1 $2/g;

      But then I think it still would not fit the description as it
      woud not split something like "Test1Test2" into "Test1 Test2"
      So following your line of thought it should be something like
      $s =~ s/([^A-Z])([A-Z])/$1 $2/g;


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://425168]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2018-02-18 20:12 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (257 votes). Check out past polls.