开发者

matching table tag by regular expression in php

I need to match a substring in php substring is like

<table class="tdicerik" id="dgVeriler"

I wro开发者_StackOverflow社区te a regular expression to it like <table\s*\sid=\"dgVeriler\" but it didnot work where is my problem ?


You forgot a dot:

<table\s.*\sid="dgVeriler"

would have worked.

<table\s+.*?\s+id="dgVeriler"

would have been better (making the repetition lazy, matching as little as possible).

<table\s+[^>]*?\s+id="dgVeriler"

would have been better still (making sure that we don't accidentally match outside of the <table>tag).

And not trying to parse HTML with regular expressions, using a parser instead, would probably have been best.


I dont know what you want get but try this:

<table\s*.*id=\"dgVeriler\"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜