Results 1 to 4 of 4

Thread: [RESOLVED] [02/03] Regex Problem : URGENT

  1. #1

    Thread Starter
    Hyperactive Member Coool's Avatar
    Join Date
    Feb 2006
    Location
    System.Coool
    Posts
    333

    Resolved [RESOLVED] [02/03] Regex Problem : URGENT

    Hi all,

    I need urgent help regarding Regular Expression.

    I m retieving whole page as HTML codes.

    Now i want to retrieve code inside any perticular HTML tag like tr/div according to it's id.

    I want to make use of regular expression but some how im not getting right result.

    Dim reg As New System.Text.RegularExpressions.Regex("<tr id=""xyz""[^>]*>(?<innerValue>([^<].*))</tr>.*", RegexOptions.IgnoreCase Or RegexOptions.Compiled Or RegexOptions.Multiline)


    e.g.

    <html>
    <table ...>
    <tr id='xyz' style='....'><td> in XYZ</td> </tr>
    <tr id='abc' style='....'><td> in ABC</td></tr>
    </table>
    </html>

    i want inner value of tr e.g. "<td> in XYZ</td>" if id is 'xyz'
    "<td> in ABC</td>" if id is 'abc'

    I hope u understand.

    thanks in advanced
    I am using .NET 2010 with Windows 7

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [02/03] Regex Problem : URGENT

    So if you use:

    <tr id="xyz"[^>]*>(?<innerValue>(.*))</tr>.*

    You will get

    <td> in XYZ</td>

    Which should be right since you mentioned "i want to retrieve code inside any perticular HTML tag like tr/div according to it's id."

  3. #3

    Thread Starter
    Hyperactive Member Coool's Avatar
    Join Date
    Feb 2006
    Location
    System.Coool
    Posts
    333

    Re: [02/03] Regex Problem : URGENT

    Sorry, I have already tried it.. it gives
    in XYZ</td> </tr><tr id='abc' style='....'><td> in ABC</td>

    before the last </tr> value.. how can i find the value before the first occurance of </tr>

    Any suggestion..
    I am using .NET 2010 with Windows 7

  4. #4

    Thread Starter
    Hyperactive Member Coool's Avatar
    Join Date
    Feb 2006
    Location
    System.Coool
    Posts
    333

    Re: [02/03] Regex Problem : URGENT

    anyway, i solved it.
    I am using .NET 2010 with Windows 7

Posting Permissions

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



Click Here to Expand Forum to Full Width