resource/horizontal_maker/company1/index.html
여기서요 horizontal_maker/company1 이런식으로 만들고싶은데요 어떻게 해야하나요?
|
답변 2개 / 댓글 1개
이에스씨코리아
2017-12-03 (일) 11:17:01
질문자 의도가 자바스크립트 기준으로 볼 때, 이런 코드가 될 것 같네요
Copy
var str = 'resource/horizontal_maker/company1/index.html';
var re = /resource\/([^\/]+)\/([^\/]+)\/index.html/;
str.replace(re, '$1/$2')
// => "horizontal_maker/company1"
2017-12-02 (토) 20:31:39
구체적인 경우를 알 수는 없지만 질문만으로 보자면
$str = "resource/horizontal_maker/company1/index.html";
$str = preg_replace("/.+(horizontal_maker\/company1).+/", "$1", $str);
echo $str;
답변에 대한 댓글 1개
답변을 작성하려면 로그인이 필요합니다.