str="<p class=\"drug-subtitle\"><b>Generic Name:</b> albuterol inhalation (al BYOO ter all)<br><b>Brand Names:</b> <i>Accuneb, ProAir HFA, Proventil, Proventil HFA, ReliOn Ventolin HFA, Ventolin HFA</i></p>"
br=re.match("<p> class=\"drug-subtitle\"[^>]*>(.*?)</p>",str)
br 반환 없음
내가 사용한 정규식의 오류는 무엇입니까?
입력을받은 경우 :
'<p class="drug-subtitle"><b>Generic Name:</b> albuterol inhalation (al BYOO ter all)<br><b>Brand Names:</b> <i>Accuneb, ProAir HFA, Proventil, Proventil HFA, ReliOn Ventolin HFA, Ventolin HFA</i></p>'
다음 사항을 확인하고 싶습니다.
<p class="drug-subtitle"> .. some items here .. </p>
입력에 존재하는 경우 사용할 정규식은 다음과 같습니다.
\<p\sclass=\"drug-subtitle\"[^>]*>(.*?)\<\/p\>
기술:
\< matches the character < literally
p matches the character p literally (case sensitive)
\s match any white space character [\r\n\t\f ]
class= matches the characters class= literally (case sensitive)
\" matches the character " literally
drug-subtitle matches the characters drug-subtitle literally (case sensitive)
\" matches the character " literally
[^>]* match a single character not present in the list below
Quantifier: Between zero and unlimited times, as many times as possible,
giving back as needed.
> a single character in the list > literally (case sensitive)
> matches the character > literally
1st Capturing group (.*?)
.*? matches any character (except newline)
Quantifier: Between zero and unlimited times, as few times as possible,
expanding as needed.
\< matches the character < literally
\/ matches the character / literally
p matches the character p literally (case sensitive)
\> matches the character > literally
따라서 정규식의 문제는 다음과 같습니다.
이것이 도움이 되었기를 바랍니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다