hi

i have run into a problem i have trying to remove some text from uesr inputs

for example if i have the code listed below

i need to strip off the secound part of the url value leaving the results as

i have tryed all sorts of patterns to try and strip the end url and the end </a> tag from the results with no luck

can anyone help me in a regular experssion to use to strip these unwanted urls and end a tag from my inputs

i was trying a experssion like this

$body[$xx] = preg_replace ("/-url<\/a>/", "[-url]", $body[$xx]);

but it strips out all of the urls, i only need the part between [-url] to </a> removed

thanks in advance, i'm still quite new to using these experssions to remove text and have been on this hours now with no luck

    Let me see if I can help. Just going to give you some variation of what I have used and see if one of them does the trick.

    preg_replace("/.-url<\/a>./", "", $string)

    or

    preg_replace("/-url<\/a>/", "", $string)

    One of them should do it or some thing close to that.

    Also do abit of research on php.net. http://us3.php.net/manual/en/book.pcre.php has alot of info. Particularly the information under the "PCRE Patterns" and its sub categories.

    As well I found a few very good sites that explain regex by searching google. Wish I could find the one I had up a few weeks ago that one got me going with the variation of what i just gave you above.

      You can also just fetch what you want out of preg_match_all, like so:

      $str = <<<DATA
      [url]http://rapidshare.com/files/102260997/TW_-_A_by_WK.part3.rar[-url]http://rapidshare.com/files/10226099...y_WK.part3.rar</a>
      [url]http://rapidshare.com/files/102263798/TW_-_A_by_WK.part4.rar[-url]http://rapidshare.com/files/10226379...y_WK.part4.rar</a>
      DATA;
      
      preg_match_all('#(\[url\][^[]+\[-url\])#', $str, $matches);
      echo '<pre>';
      print_r($matches[1]);
      echo '</pre>';
      

      Output:

      Array
      (
          [0] => [url]http://rapidshare.com/files/102260997/TW_-_A_by_WK.part3.rar[-url]
          [1] => [url]http://rapidshare.com/files/102263798/TW_-_A_by_WK.part4.rar[-url]
      )
      
        Write a Reply...