Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jul 2008
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Finding value between two words

    Hi,

    I am trying to find the text between 2 words.

    The text I am looking at is partly:
    Code:
    #header{
    background-image:url(/stylesheets/images/t1header.jpg);
    height:120px
    }
    #headerText{
    I have got:
    preg_match("(header{(/?[^\>]+)#headerText)",$cssSource,$matches);
    //cssSource is the above style code

    This also returns the header{ and #headerText in matches. How can I get it to return just the text in between and not the two searched words.

    At the moment the above code returns:
    header{ background-image:url(/stylesheets/images/t100-1header.jpg); height:120px } #headerText

    But i just want:
    background-image:url(/stylesheets/images/t100-1header.jpg); height:120px

    Thanks for any help

    K

  • #2
    Regular Coder Apothem's Avatar
    Join Date
    Mar 2008
    Posts
    380
    Thanks
    36
    Thanked 25 Times in 25 Posts
    I'm not entirely sure if this will help, but:
    PHP Code:
    $string = <<<A
    #header{
    background-image:url(/stylesheets/images/t1header.jpg);
    height:120px
    }
    #headerText{
    A;

    preg_match("#background(.*)#"$string$varPREG_OFFSET_CAPTURE);
    print_r($var); 
    Was able to give me something alike.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •