나는 정규 표현식을 가지고 그것은 수 댓글을 제외하는 정규식?</p> <pre><code>(/*([^*]|[rn]|(*+([^*/]|[rn])))**+/)|(//.*) </code></pre> <p>을 그리고 내 테스트 문자열은 다음과 같이 다음과 같이
https://regex101.com/r/lx2f5F/1
가 라인 2, 4 일치
<?
/* This is a comment */
cout << "Hello World"; // prints Hello World
/*
* C++ comments can also
*/
cout << "Hello World";
/* Comment out printing of Hello World:
cout << "Hello World"; // prints Hello World
*/
echo "//This line was not a Comment, but ... ";
echo "http://stackoverflow.com";
echo 'http://stackoverflow.com/you can not match this line';
array = ['//', 'no, you can not match this line!!']
/* This is * //a comment */
~ 9 (7), (13) ~ 17 올바르게.
그러나 그것은 또한, 방법 비 욕심 매칭?
어떤 도움이 기꺼이 감상 할 수있다.
정규식 * for * 란 무엇입니까? 그리고 왜*? – jonrsharpe
명확하게 언급하고 싶은 라인이나 일치하지 않는 라인을 ... 우리가 정규식에서 이해해야한다면 당신의 정규식은 정확해야합니다. 따라서 짐작할 시간이 없습니다. –
This 질문에 이미 답변이 있습니다. 여기를 볼 수 있습니다! http://stackoverflow.com/a/41867753/2012407 – antoni