Regular expression help

Discussion in 'PHP' started by pluswebdev, Oct 7, 2008.

  1. #1
    Hi,
    will be happy if someone help me with this. I think it can be done with regular expression.

    Lets the input text is "HereIsExampleText"

    and I want the result to be "Here Is Example Text"
     
    pluswebdev, Oct 7, 2008 IP
  2. ads2help

    ads2help Peon

    Messages:
    2,142
    Likes Received:
    67
    Best Answers:
    1
    Trophy Points:
    0
    #2
    use this :
    $string = 'HereIsExampleText';
    $pattern = "/([A-Z])/";
    $result = preg_replace($pattern," $1",$string);
    print $result;
    PHP:
    hope it helps u good luck =D
     
    ads2help, Oct 7, 2008 IP
    pluswebdev likes this.
  3. GuitarFix

    GuitarFix Peon

    Messages:
    37
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Wow. Great solve!

    And then we can use it:
    $result = ltrim( $result );
    PHP:
    to remove the first space.
     
    GuitarFix, Oct 7, 2008 IP
    pluswebdev likes this.
  4. pluswebdev

    pluswebdev Banned

    Messages:
    205
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #4
    @ads2help thanks, rep added
     
    pluswebdev, Oct 7, 2008 IP