Confusing Regular Expression
Moderator: General Moderators
-
chris12295
- Forum Contributor
- Posts: 113
- Joined: Sun Jun 09, 2002 10:28 pm
- Location: USA
- Contact:
Confusing Regular Expression
i need to split some text on this text: <tr style='mso-yfti-irow:0'>
or this text: <tr>
and also the same thing with <td>
but i cant figure out a good regular expression to use with split().
any ideas?
or this text: <tr>
and also the same thing with <td>
but i cant figure out a good regular expression to use with split().
any ideas?
-
Illusionist
- Forum Regular
- Posts: 903
- Joined: Mon Jan 12, 2004 9:32 pm
-
chris12295
- Forum Contributor
- Posts: 113
- Joined: Sun Jun 09, 2002 10:28 pm
- Location: USA
- Contact:
-
Illusionist
- Forum Regular
- Posts: 903
- Joined: Mon Jan 12, 2004 9:32 pm
so maybe something like:
Code: Select all
$regexp = "#\<tr.*?>(.*?)</tr>#is";-
Illusionist
- Forum Regular
- Posts: 903
- Joined: Mon Jan 12, 2004 9:32 pm
try this:
Code: Select all
$trText = "<tr width=100 height=100>Here </tr><tr bgcolor=#ffffff>is some </tr><tr>TeXt</tr>";
$regexp = "#\<tr.*?>(.*?)</tr>#is";
$c = preg_match_all($regexp,$trText,$match);
for ($i=0; $i<$c; $i++) {
echo $match[0][$i];
}
//returns Here is Some TeXt-
chris12295
- Forum Contributor
- Posts: 113
- Joined: Sun Jun 09, 2002 10:28 pm
- Location: USA
- Contact:
-
Illusionist
- Forum Regular
- Posts: 903
- Joined: Mon Jan 12, 2004 9:32 pm
-
TheBentinel.com
- Forum Contributor
- Posts: 282
- Joined: Wed Mar 10, 2004 1:52 pm
- Location: Columbus, Ohio
I am definitely not a regexp guy, but something related to [!<] might get you closer.chris12295 wrote:not quite what i need. I need a pattern for preg_split()
and also, i just want it to match a <tr> tag, NOT <tr>text</tr>
basically i need somthing like this <tr.*> except that is greedy (it will match everything until the last > in the document)
<tr[!<]*> maybe?
Shooting blind here, I never touch regexp's. They see me coming and start lining up their crosshairs on my foot.