正则表达式:我该如何匹配第一个

时间:2020-08-30 18:21:11

标签: regex pcre

我在此站点(https://www.debuggex.com/)中尝试这样的“ \ <\%。* \%\>”,但匹配了两个字符串。 因此,我只想匹配下面一行中的第一件事。我该怎么办?

BLA BLA文本文本<%eval request(“ BLA”)%>文本<%eval request(“ BLA”)%>文本BLA

谢谢。

1 个答案:

答案 0 :(得分:-1)

尝试一下(不带全局标志):

<style> #pricing {margin-top: 20px; display: flex; flex-direction: row; justify-content: center;} .product {display: flex; flex-direction: column; align-items: center; text-align: center; width: calc(100% / 3); margin: 10px; border: 1px solid #000; border-radius: 3px;} .product > .level {background-color: #ddd; color: black; padding: 15px 0; width: 100%; text-transform: uppercase; font-weight: 700;} .product > h2 {margin-top: 25px;} .product > ol {margin: 5px 0;} .product > ol > li {padding: 2px 0; color: black;} .product > button {border: 0; margin: 25px 0; background-color: #dee21e; font-weight: 400; font-family: oswald; width: 120px; height: 30px;} .product > button:hover {background-color: white; transition: background-color 1s;} @media (max-width: 800px) {#pricing {flex-direction: column;} .product {max-width: 300px; width: 100%; margin: 0 auto; margin-bottom: 10px;} </style> <section id="pricing"> <div class="product" id="avanti"> <div class="level">Avanti West Coast</div> <h2>$15/month</h2> <ol> <li>Travel the west coast for cheaper.</li> <li>Lorem ipsum.</li> <li>Lorem ipsum dolor.</li> <li>Lorem ipsum.</li> </ol> <button class="btn">Learn More</button> </div> <div class="product" id="crosscountry"> <div class="level">CrossCountry</div> <h2>$20/month</h2> <ol> <li>Take your train trip up a notch with CrossCountry.</li> <li>Lorem ipsum.</li> <li>Lorem ipsum dolor.</li> <li>Lorem ipsum.</li> </ol> <button class="btn">Learn More</button> </div> <div class="product" id="gwr"> <div class="level">GWR</div> <h2>$25/month</h2> <ol> <li>Travel Europe for much cheaper with GWR.</li> <li>Great for the East coast.</li> <li>Lorem ipsum dolor.</li> <li>Lorem ipsum.</li> </ol> <button class="btn">Learn More</button> </div> </section>

您可以在此处找到PCRE的示例:https://regex101.com/r/lcjAvZ/1

相关问题