[펌] 정규식을 사용하여 특정태그에서 텍스트만 불러오고 싶습니다...ㅜㅜ 정보
기타 [펌] 정규식을 사용하여 특정태그에서 텍스트만 불러오고 싶습니다...ㅜㅜ
관련링크
본문
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="view_ditail" id="contents_td" style='overflow-x:auto; word-break:break-all;'>
<TABLE width="100%" border=0> <TBODY> <TR> <TD class=board_write_table_style colSpan=10> <TABLE id=tbBoardView style="BORDER-COLLAPSE: collapse" cellSpacing=0 cellPadding=0 width="100%" border=0> <TBODY> <TR> <TD class=board_read_textarea_cell_style vAlign=top colSpan=2 height=200><SPAN class=board_comment_text id=textContent> 학원명 : 참사랑내신스쿨</FONT></P> </FONT> </P> 모 집 : 초, 중 영어선생님</FONT></P> 초, 중 수학선생님</FONT></P> 전임선생님 및 보조선생님</FONT></P> </FONT> </P> 보 수 : 전임 - 140이상</FONT></P> 보조 - 타임당 20~30정도</FONT></P> </FONT> </P> 근 무 : 6개월이상가능자</FONT></P> </FONT> </P> 연락처 : 011 xxx 8217</FONT></P></SPAN></TD> <TD class=board_read_content_cell_style><INPUT id=fileName type=hidden name=fileName></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR><TR><TD> <TABLE width="100%" border=0> <TBODY> <TR> <TD> <TABLE id=tbComment style="BORDER-COLLAPSE: collapse" cellSpacing=0 cellPadding=0 width="100%" border=0> <TBODY> <TR> <TD> </P></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR><TR><TD></TD></TR>
</td>
</tr>
<tr>
<td class="tr_line"> </td>
</tr>
</table
-------------------------------------------------------------------------------------------------------------------------------
우선 이 안에 있는 텍스트 값만 불러 오고 싶습니다.
조건은... <td class="view_ditail" 이 td 안에 있는 텍스트를 불러오는식으로 하려고합니다..
td 안에 또다른 많은 태그들이 있는데 어떤 정규식으로 풀어야할지 고민입니다.
답변 부탁드릴께요...<div class='small'>[이 게시물은 관리자님에 의해 2011-10-31 18:00:23 Regular Expression (정규표현식)에서 이동 됨]</div>
<tr>
<td class="view_ditail" id="contents_td" style='overflow-x:auto; word-break:break-all;'>
<TABLE width="100%" border=0> <TBODY> <TR> <TD class=board_write_table_style colSpan=10> <TABLE id=tbBoardView style="BORDER-COLLAPSE: collapse" cellSpacing=0 cellPadding=0 width="100%" border=0> <TBODY> <TR> <TD class=board_read_textarea_cell_style vAlign=top colSpan=2 height=200><SPAN class=board_comment_text id=textContent> 학원명 : 참사랑내신스쿨</FONT></P> </FONT> </P> 모 집 : 초, 중 영어선생님</FONT></P> 초, 중 수학선생님</FONT></P> 전임선생님 및 보조선생님</FONT></P> </FONT> </P> 보 수 : 전임 - 140이상</FONT></P> 보조 - 타임당 20~30정도</FONT></P> </FONT> </P> 근 무 : 6개월이상가능자</FONT></P> </FONT> </P> 연락처 : 011 xxx 8217</FONT></P></SPAN></TD> <TD class=board_read_content_cell_style><INPUT id=fileName type=hidden name=fileName></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR><TR><TD> <TABLE width="100%" border=0> <TBODY> <TR> <TD> <TABLE id=tbComment style="BORDER-COLLAPSE: collapse" cellSpacing=0 cellPadding=0 width="100%" border=0> <TBODY> <TR> <TD> </P></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR><TR><TD></TD></TR>
</td>
</tr>
<tr>
<td class="tr_line"> </td>
</tr>
</table
-------------------------------------------------------------------------------------------------------------------------------
우선 이 안에 있는 텍스트 값만 불러 오고 싶습니다.
조건은... <td class="view_ditail" 이 td 안에 있는 텍스트를 불러오는식으로 하려고합니다..
td 안에 또다른 많은 태그들이 있는데 어떤 정규식으로 풀어야할지 고민입니다.
답변 부탁드릴께요...<div class='small'>[이 게시물은 관리자님에 의해 2011-10-31 18:00:23 Regular Expression (정규표현식)에서 이동 됨]</div>
추천
0
0
댓글 1개

preg_match("#<td class=\"view_ditail\"[^>]+\>(.*)</td></tr><tr><td>#is", $str, $matches);
echo trim($matches[1]);
결과 :
<TABLE width="100%" border=0> <TBODY> <TR> <TD class=board_write_table_style colSpan=10> <TABLE id=tbBoardView style="BORDER-COLLAPSE: collapse" cellSpacing=0 cellPadding=0 width="100%" border=0> <TBODY> <TR> <TD class=board_read_textarea_cell_style vAlign=top colSpan=2 height=200><SPAN class=board_comment_text id=textContent> 학원명 : 참사랑내신스쿨</FONT></P> </FONT> </P> 모 집 : 초, 중 영어선생님</FONT></P> 초, 중 수학선생님</FONT></P> 전임선생님 및 보조선생님</FONT></P> </FONT> </P> 보 수 : 전임 - 140이상</FONT></P> 보조 - 타임당 20~30정도</FONT></P> </FONT> </P> 근 무 : 6개월이상가능자</FONT></P> </FONT> </P> 연락처 : 011 xxx 8217</FONT></P></SPAN></TD> <TD class=board_read_content_cell_style><INPUT id=fileName type=hidden name=fileName></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR><TR><TD> <TABLE width="100%" border=0> <TBODY> <TR> <TD> <TABLE id=tbComment style="BORDER-COLLAPSE: collapse" cellSpacing=0 cellPadding=0 width="100%" border=0> <TBODY> <TR> <TD> </P></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>
echo trim($matches[1]);
결과 :
<TABLE width="100%" border=0> <TBODY> <TR> <TD class=board_write_table_style colSpan=10> <TABLE id=tbBoardView style="BORDER-COLLAPSE: collapse" cellSpacing=0 cellPadding=0 width="100%" border=0> <TBODY> <TR> <TD class=board_read_textarea_cell_style vAlign=top colSpan=2 height=200><SPAN class=board_comment_text id=textContent> 학원명 : 참사랑내신스쿨</FONT></P> </FONT> </P> 모 집 : 초, 중 영어선생님</FONT></P> 초, 중 수학선생님</FONT></P> 전임선생님 및 보조선생님</FONT></P> </FONT> </P> 보 수 : 전임 - 140이상</FONT></P> 보조 - 타임당 20~30정도</FONT></P> </FONT> </P> 근 무 : 6개월이상가능자</FONT></P> </FONT> </P> 연락처 : 011 xxx 8217</FONT></P></SPAN></TD> <TD class=board_read_content_cell_style><INPUT id=fileName type=hidden name=fileName></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR><TR><TD> <TABLE width="100%" border=0> <TBODY> <TR> <TD> <TABLE id=tbComment style="BORDER-COLLAPSE: collapse" cellSpacing=0 cellPadding=0 width="100%" border=0> <TBODY> <TR> <TD> </P></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>