+ Reply to Thread
Results 1 to 2 of 2

Thread: Remove Tags from Regex pattern match

  1. #1
    Junior Member
    Join Date
    Jan 2012
    Posts
    35

    Remove Tags from Regex pattern match

    I have created a Regex Pattern that matches text and display results
    Code:
    $sPattern = "/<\/td><td>\(My_Word\)(.*?)<\/td><td>/";
    preg_match_all($sPattern,$homepage,$aMatch);
    But the problem is that matches are inside table and the result is like : <td>My_Word</td> , so is there any way i
    could get rid of these Tags ?

  2. #2
    Junior Member
    Join Date
    Jun 2012
    Posts
    15
    Okay so all matches are stored in array , so let`s retrieve each match :
    Code:
    foreach( $aMatch[1] as $match)
        echo $match;
    If you want "(Shotgun)" in the output as well, modify your regex to capture it:
    Code:
    $sPattern = "/<\/td><td>(\(My_Word)\).*?)<\/td><td>/";

+ Reply to Thread

Bookmarks

Posting Permissions

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