regex - Find after pattern plus next line -
in html file php included
<table> <tbody> <tr> <td>td1</td> <td>td2</td> </tr> <tr> <td colspan="3"> <?php echo 'something' ?> </td> <td> <?php echo echo 'something' ?> </td> <td> <?php echo 'something' ?> </td> </tr> </tbody> </table>
i'd find <?php
comes after <td ...>
+ next line.
(here not td1
, not td2
)
approach:
(?s)(<td.*?>)+(\n)
... matches <td>td1</td>
, <td>td2</td>
what comes after (?s)(<td.*?>)
?
to remove <?php...?>
can replace (<td[^>]*>)\s*<\?php.*?\?>
$1
:
explaining:
(<td[^>]*>) # store in $1 want retrieve \s* # match want remove <\?php.*?\?> # php content
then when replacing $1
remove \s*<\?php.*?\?>
depended on <td>
hope helps.
Comments
Post a Comment