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\"
精彩评论