정규식으로 유투브 주소에서 아이디 값만 추출
<script>
function youtubeId(url) {
var tag = "";
if(url) {
var regExp = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/;
var matchs = url.match(regExp);
if (matchs) {
tag += "유튜브 아이디 : "+matchs[7];
}
return tag;
}
}
var s1 = "https://www.youtube.com/watch?v=pAWk-yh2ysc";
var s2 = "http://youtu.be/WUzwkGmnAaw";
document.write(youtubeId(s1));
document.write("<br />");
document.write(youtubeId(s2));
</script>
게시판 목록
개발자팁
개발과 관련된 유용한 정보를 공유하세요.
질문은 QA에서 해주시기 바랍니다.
질문은 QA에서 해주시기 바랍니다.
| 번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|---|
| 4766 | jQuery | 8년 전 | 1681 | ||
| 4765 | jQuery | 8년 전 | 1354 | ||
| 4764 | jQuery | 8년 전 | 2168 | ||
| 4763 | jQuery | 8년 전 | 1856 | ||
| 4762 | jQuery | 8년 전 | 1634 | ||
| 4761 | jQuery | 8년 전 | 1936 | ||
| 4760 | jQuery | 8년 전 | 1301 | ||
| 4759 | jQuery | 8년 전 | 1599 | ||
| 4758 | jQuery | 8년 전 | 1316 | ||
| 4757 | jQuery | 8년 전 | 1281 | ||
| 4756 | jQuery | 8년 전 | 1499 | ||
| 4755 | jQuery | 8년 전 | 1651 | ||
| 4754 | jQuery | 8년 전 | 1619 | ||
| 4753 | jQuery | 8년 전 | 1775 | ||
| 4752 | jQuery | 8년 전 | 1523 | ||
| 4751 | jQuery | 8년 전 | 1844 | ||
| 4750 | jQuery | 8년 전 | 1983 | ||
| 4749 | jQuery | 8년 전 | 1443 | ||
| 4748 | PHP | 8년 전 | 2811 | ||
| 4747 | jQuery | 8년 전 | 1394 | ||
| 4746 | jQuery | 8년 전 | 1650 | ||
| 4745 | jQuery | 8년 전 | 1658 | ||
| 4744 | jQuery | 8년 전 | 1537 | ||
| 4743 | jQuery | 8년 전 | 1618 | ||
| 4742 | jQuery | 8년 전 | 1709 | ||
| 4741 | jQuery | 8년 전 | 1602 | ||
| 4740 | jQuery | 8년 전 | 1610 | ||
| 4739 | jQuery | 8년 전 | 1799 | ||
| 4738 | jQuery | 8년 전 | 1317 | ||
| 4737 | jQuery | 8년 전 | 2104 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기