#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2008
    Posts
    152
    Rep Power
    0

    Looking for RegEx pattern to retrieve data inside <b> tags


    The following RegEx expressions retrieves <B>HI</B> and <B>CA</B>, but I'm only interested in retrieving the data inside the tags (HI and CA), WITHOUT KNOWING WHAT IS INSIDE THE TAGS.

    The string:

    PHP Code:
    The offer is not available to customers living in <B>HI</B> and <B>HI</B
    RegEx That I'm currently using:
    PHP Code:
    <[Bb]>.+?</[Bb]> 
    Last edited by cd_gary; August 29th, 2008 at 11:43 AM. Reason: Edit
  2. #2
  3. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,908
    Rep Power
    6352
    PHP Code:
    $yourString " The offer is not available to customers living in <B>HI</B> and <B>CA</B> ";
    preg_match_all("#<b[^>]*>(.+)</b>#iU"$yourString$foo);
    print_r($foo[1]); 
    -Dan
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.

IMN logo majestic logo threadwatch logo seochat tools logo