[정규식] 재미난? 정규식 Again #11 - 속성편 정보
[정규식] 재미난? 정규식 Again #11 - 속성편본문
@그누스트랩 님의 QA에 올라온 질문입니다.
-------------------------------------------
<video id="ppom_gif_video_view0" name="ppom_gif_video_player" style="max-width:100%; width:269px;height:auto;">
<video name="ppom_gif_video_player" id="ppom_gif_video_view0" style="max-width:100%; width:269px;height:auto;">
<video name="ppom_gif_video_player" style="max-width:100%; width:269px;height:auto;" id="ppom_gif_video_view0">
-------------------------------------------
세줄이 같은 내용인데 id위치만 바꾼 것입니다.
옵션은 /g 로 하시고..
정규식으로 id부분을 통째로 잡는 것입니다.
제가 만든식으로는 다음과 같이 나옵니다. 그룹을 사용합니다. 빨간색 부분이 id로 시작하는 것을 그룹 1로 잡은 모습입니다. (html태그안에 어디에 있어도 잡아야 됩니다.)
PHP라면
preg_match(정규식, "${1} controls ${2}${3}", $view['content']);
으로 하면 id= 앞에 controls 가 들어 갑니다.
추천
0
0
댓글 0개