정규식 질문좀 드릴게요 ㅠ 채택완료
이런코드가잇는데 18,650만 못뽑습니다. 여기까지 검색하고 18,650만 뽑을수 있는 방법이 있을까요? 예제좀 알려주세요 ㅠ
댓글을 작성하려면 로그인이 필요합니다.
댓글을 작성하려면 로그인이 필요합니다.
댓글을 작성하려면 로그인이 필요합니다.
굳이 꼭 정규식으로 구해야하는 이유가 있나요? 클래스나 아이디를 넣어서 자바스크립트로 셀렉트 하실수는 없으신 상황이신건가요?
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
소계
+6,200
-1,400
보유포인트
18,650
겹치는부분이 너무많아서
보유포인트 이거부터
이사이 검색해서
답변
4개
</p>
<p>$str = <<<HEREDOC
<tr class="active">
<th></th>
<th scope="row">소계</th>
<th></th>
<td align="right"><b>+6,200</b></td>
<td align="right"><b>-1,400</b></td>
<td></td>
</tr>
<tr class="bg-black">
<th></th>
<th scope="row">보유포인트</th>
<th></th>
<td align="right"><b>18,650</b></td>
<td></td>
<td></td>
HEREDOC;</p>
<p> </p>
<p>preg_match_all('@<th scope="row">보유포인트</th>.*?<td align="right"><b>(.*?)</b></td>@s', $str, $arr);</p>
<p>
print_r($arr);</p>
<p>/*</p>
<p>Array
(
[0] => Array
(
[0] => <th scope="row">보유포인트</th>
<th></th>
<td align="right"><b>18,650</b></td>
)</p>
<p> [1] => Array
(
[0] => 18,650
)</p>
<p>)</p>
<p>*/</p>
<p></p>
<p>$html = '<code><tr class="active"></p>
<p><th></th></p>
<p><th scope="row">소계</th></p>
<p><th></th></p>
<p><td align="right"><b>+6,200</b></td></p>
<p><td align="right"><b>-1,400</b></td></p>
<p><td></td></p>
<p></tr></p>
<p><tr class="bg-black"></p>
<p><th></th></p>
<p><th scope="row">보유포인트</th></p>
<p><th></th></p>
<p><td align="right"><b>18,650</b></td></p>
<p><td></td></p>
<p><td></td></p>
<p> </p>
<p></code>';</p>
<p>preg_match_all('/<b(.*?)>(.*?)<\/b>/i', $html, $p_match);</p>
<p> </p>
<p>print_r2($p_match);</p>
<p>Array</p>
<p>(
[0] => Array
(
[0] => <b>+6,200</b>
[1] => <b>-1,400</b>
[2] => <b>18,650</b>
)
[1] => Array
(
[0] =>
[1] =>
[2] =>
)
[2] => Array
(
[0] => +6,200
[1] => -1,400
[2] => 18,650
)
)</p>
<p>
아르키어드답변에 대한 댓글 1개
전체 질문 목록