Re: how to add a space using a regex




Jerry Preston wrote:
> What I want to do is add a space between one's name when the are like the
> following:
>
> $name1 = "FirstLast:";
>
> I want change $name1 = "First Last";
>
> and
>
> $name1 = "FirstMiddleLast:";
>
> I want change $name1 = "First Middle Last";
>
> To be able to add spaces for either "FirstLast:" or "FirstMiddleLast:" with
> the same regex?

In Ruby:

name1.gsub!(/(.)([A-Z])/,'\1 \2')

.



Relevant Pages

  • Re: reducing a regex
    ... Jerry Preston wrote: ... snip ... ... It's difficult to give any specific advice without your own idea of what the ... regex should be doing. ...
    (comp.lang.perl.misc)
  • Re: reducing a regex
    ... Jerry Preston wrote in comp.lang.perl.misc: ... Then why don't you give an example that your regex actually matches? ... extracts the same fields. ... Anno ...
    (comp.lang.perl.misc)
  • RE: is there away to regex
    ... I am converting c to basic. ... is there away to regex ... In article, Jerry Preston ... To unsubscribe, e-mail: beginners-unsubscribe@perl.org ...
    (perl.beginners)