开发者

matching table tag by regular expression in php

开发者 https://www.devze.com 2023-01-16 08:16 出处:网络
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\\

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

精彩评论

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