Results 1 to 2 of 2
  1. #1
    kovitch is offline Member
    Join Date
    Sep 2011
    Posts
    1
    Rep Power
    0

    Default Regular expressions (REGEX)

    Hi,

    I'm trying to make a regular expression for 2 kinds of situation (on with link on the other without):

    Java Code:
    1:  <td class="nfo">microSD, up to 32GB, <a href=http://a.gsmarena.com/adclick.php?bannerid=137&zoneid=9&source=&dest=http%3A%2F%2Fgsmarena.pgpartner.com%2Fsearch_attrib.php%2Fpage_id%3D152%2Fpopup1%5B%5D%3D75%3A105 target=_blank>buy memory</a></td></tr>
    or
    2:  <td class="nfo">microSD, up to 16GB</td></tr>
    The regular expression that I have is:

    Java Code:
    p_spec = Pattern.compile("<td[\\s]class=\"nfo\">(.+?)(,\\s)(?i)<a([^>]+)>(.+?)</a></td>");
    When the expression is used in the 1st piece of code the result i got (applying p_spec.matcher("")) is: "microSD, up to 32GB".
    When I use the expression in the 2nd piece of code I don't get any result at all.

    How can I change the regular expression in order to get info from the 1st and the 2nd lines?

    Best regards.

  2. #2
    Petr's Avatar
    Petr is offline Senior Member
    Join Date
    Jan 2011
    Location
    Russia
    Posts
    620
    Rep Power
    4

Similar Threads

  1. Regular Expressions Help
    By Death Sickle in forum New To Java
    Replies: 4
    Last Post: 04-04-2011, 05:21 AM
  2. Regular Expressions problem
    By mohammedelbes in forum Advanced Java
    Replies: 7
    Last Post: 01-05-2011, 12:12 PM
  3. regular expressions
    By sozeee in forum New To Java
    Replies: 3
    Last Post: 12-06-2010, 10:58 PM
  4. Regular Expressions in java
    By blue404 in forum Advanced Java
    Replies: 2
    Last Post: 09-26-2008, 04:43 AM
  5. Handling regular expressions using Regex
    By Java Tutorial in forum Java Tutorial
    Replies: 0
    Last Post: 01-07-2008, 01:46 PM

Posting Permissions

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