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;
--
edan

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;
    (untested)
      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;

      si_lence