khsater
asked on
Extract table from html file string - Regular Expression?
I'm opening and reading an HTML file into a string using PHP. I don't excel at regular expressions so I'm looking for some help. I need to be able to extract one table from this HTML file that I know will always come immediately after the string "<p>Click on Course ID link in the first column to drop/change a class.</p>", two newline characters and maybe a little white-space ( a single tab or whatever that translates into ). I'm pretty sure this table will always start at the same line, but it will not always end at the same line. Is this easily done using regular expressions?
Here's what I'm trying to do. The table has some information I'm trying to extract, but I'm going to do it using JavaScript. So, I'm trying to extract the info from an uploaded file into a php script that will print it so that when the page is loaded I can use JavaScript's DOM to gather the info. I'm open to suggestions as an alternate method (i.e. a PHP table parser), but I'm on a shared server and I don't want to deal with any added extensions.
Here's what I'm trying to do. The table has some information I'm trying to extract, but I'm going to do it using JavaScript. So, I'm trying to extract the info from an uploaded file into a php script that will print it so that when the page is loaded I can use JavaScript's DOM to gather the info. I'm open to suggestions as an alternate method (i.e. a PHP table parser), but I'm on a shared server and I don't want to deal with any added extensions.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Not sure. the surrounding / / are just normal notation for regular expressions. Those are probably left off in PHP if I recall.
ASKER
That wasn't it. The surrounding slashes are included in PHP pregs.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Pattern modifiers etc are documented in the PCRE cheat sheet, in case you haven't seen it, available from here:
http://www.phpguru.org/article/pcre-cheat-sheet
http://www.phpguru.org/article/pcre-cheat-sheet
Thanks TerryAtOpus, I can't believe I blanked out on that one detail. I was a bit too distracted, I apologize.
Terry did the heavy lifting on that one, I feel like I took too many points. :(
Glad to help.
Glad to help.
ASKER