#1
  1. No Profile Picture
    unemployed dev junkie :(
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Posts
    32
    Rep Power
    15
    What would be the RE pattern to extract the contents of each <td> cell in the code below?
    One cell/line at a time, of course.


    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre><td><small><b>04:35p</b></small></td>
    <td align=right><small><b> &amp;nbsp; &amp;nbsp;</b></small></td>
    <td><small><b>FIN R MASSAC -R</b></small></td>
    <td align=right><small><b>906</b></small></td>
    <td align=right><small><b>&amp;nbsp;</b></small></td>
    <td align=right><small><b>&amp;nbsp;</b></small></td>
    <td align=right><small><b> 9o</b></small></td>
    <td align=right><small><b>&amp;nbsp;</b></small></td>
    <td align=right><small><b>&amp;nbsp;</b></small></td>
    <td align=right>&amp;nbsp;</td>
    <td>&amp;nbsp;</td>[/code]
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Location
    Alkmaar, The Netherlands
    Posts
    123
    Rep Power
    15
    The regexp fot one line would look something like this (assuming they all have the <small><b> tags around it, and you don't want to use them:

    /<td.*><small><b>(.*?)</b></small></td>/

    Your content is now in $1.

    you should write some loop around it to execute it one line at the time.

    ------------------
    Good luck,
    Bas

    ------------------
    E-mail me at: b.vandermeijden@pecoma.nl
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    114
    Rep Power
    15
    That would work, but only for instances where the tags are nested in that order. You could also try:

    /<[^>]*>(.*?)</[^>]*>/

    and it should match any text not within a tag.
  6. #4
  7. No Profile Picture
    unemployed dev junkie :(
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Posts
    32
    Rep Power
    15
    wouldn't it be
    /(<[^>]*> )+(.*?)(</[^>]*> )+/
    in this case ?
    .. because there are one or more opening tags and one or more closing tags around what i want to get.
    also why should i use .*? and not .+ ?

    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by billyo:
    That would work, but only for instances where the tags are nested in that order. You could also try:

    /<[^>]*>(.*?)</[^>]*>/

    and it should match any text not within a tag.
    [/quote]

Similar Threads

  1. regular expressions
    By tdennist in forum C Programming
    Replies: 2
    Last Post: January 18th, 2004, 06:01 AM
  2. regular expressions in Javascript
    By DazAdams in forum JavaScript Development
    Replies: 9
    Last Post: November 24th, 2003, 09:09 AM
  3. Getting parts outof text with regular expressions
    By GGK in forum PHP Development
    Replies: 8
    Last Post: August 31st, 2003, 07:31 AM
  4. using regular expressions in ErrorDocument 404 custom redirect??
    By wolfespawn in forum Apache Development
    Replies: 1
    Last Post: March 19th, 2003, 12:09 PM
  5. regular expressions in java
    By anulok in forum Java Help
    Replies: 2
    Last Post: March 5th, 2003, 09:53 AM

IMN logo majestic logo threadwatch logo seochat tools logo