나는이 문자열에서 내부 텍스트 얻을 필요가 [%L10n.msg('foo')%]
사이의 텍스트 있도록 [%L10n.msg('
하고 ')%]
내가 가야이 예제 정도 foo
.
많은 예제를 찾았지만 그중 아무도 작동하지 않았으므로 다음과 같이 시도했습니다.
echo "[%L10n.msg('foo')%]" | sed -n -e '/[%L10n.msg(\'/,/\')%]/p'
하지만 오류가 발생합니다.
bash : 예기치 않은 토큰`) '근처의 구문 오류
업데이트 : 내 문자열 이이 strig 안에있을 수 있다고 상상해보십시오.
Some ' very [%% ]long ' text [%L10n.msg('foo')%] with lot of [%characters%]
테스트 된 파일 :
Some ' very [%% ]long ' text [%L10n.msg('foo')%] with lot of [%characters%]
fefe
<a class="w3-bar-item w3-button" href='/html/html_examples.asp'>HTML Examples</a>
<a class="w3-bar-item w3-button" href='/html/html_exercises.asp'>HTML Exercises</a>
fefrheerghirlg wgwa g [%L10n.msg('foo')%]
<>"
어때
$ echo "[%L10n.msg('foo')%]" | sed "s/\[%L10n.msg('//; s/')%]//"
foo
또는 새로운 입력 샘플로
echo "Some ' very [%% ]long ' text [%L10n.msg('foo')%] with lot of [%characters%]" | sed "s/^.*\[%L10n.msg('//; s/')%].*$//"
foo
또는 입력이 두 번째로 변경된 경우 ( 지금 테스트 된 파일 읽기 )
sed -n "/^.*\[%L10n.msg('/ {s///; s/')%].*$//;p}" file
foo
foo
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다