簡體   English   中英

如何根據DIV標簽中的關鍵字刪除所有URL

[英]How to remove all URLs based on keywords in the DIV tags

如何刪除DIV標簽中從特定關鍵字過濾掉的特定URL。 假設我有一個這樣的文本:

<div class="target">
https://my-site.com/test1_good.html
https://my-site.com/test1_fake.html
https://my-site.com/test2_good.html
https://my-site.com/test2_fake.html
https://my-site.com/test3_good.html
https://my-site.com/test3_fake.html
</div>

在這里,我希望所有包含關鍵字"_good.html" URL都可以使結果變為:

<div class="target">
https://my-site.com/test1_good.html
https://my-site.com/test2_good.html
https://my-site.com/test3_good.html
</div>

能做到嗎? 不管使用Javascript,jQuery還是PHP。 謝謝..

這取決於您最初輸出網址的方式。 如果您正在使用PHP並以循環方式輸出它們,則可以使用preg_match() ,否則可以通過如下所示的匹配項來使用JavaScript:

<script>
$(document).ready(function() {
    // Fetch the urls
    var getCont =   $('.target').text();
    // Create storage
    var getGood =   [];
    // Loop the urls
    $.each(getCont.split('\n'),function(k,v) {
        // If contains the string, save to storage
        if(v.match(/_good/i))
            getGood.push(v);
    });
    // Tell us about it...
    console.log(getGood);
});
</script>

在控制台中,向您提供以下內容:

[
 "https://my-site.com/test1_good.html",
 "https://my-site.com/test2_good.html",
 "https://my-site.com/test3_good.html"
]

移除所有<div tags with sql query< div><div id="text_translate"><p> 我有表名wp_posts並且在post_content列中有我的帖子的描述(HTML 格式)。</p><p> 我想要一個在 post_content 列中搜索並選擇以<div class or no class>開頭的標簽並刪除整個標簽的查詢。</p><p> 我不想刪除標簽內的任何內容,只需刪除標簽</p><p>這個:</p><pre> <div> or <div clas="sada"> some text </div></pre><p> 會變成這樣:</p><pre> some text</pre><p> 我的 MYSQL 版本是 15.1。</p></div></div>

[英]Remove all <div tags with SQL Query

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

相關問題 移除所有<div>帶有查詢的標簽</div><div id="text_translate"><p>我想從內容中刪除所有<div>標簽,我使用此查詢,它只刪除沒有 class 的<div>標簽,如何刪除所有<div>,<div class"example">,</div> ?</p><pre> UPDATE wp_posts SET `post_content` = REPLACE (`post_content`, '<div>', '') WHERE `ID`=84259</pre><p> 我想要一個刪除<%div%>的查詢(% 意味着不管 div 之前和之后是什么)</p></div> 如何刪除所有標簽? 如何從內部刪除標簽 <div> 標簽 移除所有<div tags with sql query< div><div id="text_translate"><p> 我有表名wp_posts並且在post_content列中有我的帖子的描述(HTML 格式)。</p><p> 我想要一個在 post_content 列中搜索並選擇以<div class or no class>開頭的標簽並刪除整個標簽的查詢。</p><p> 我不想刪除標簽內的任何內容,只需刪除標簽</p><p>這個:</p><pre> <div> or <div clas="sada"> some text </div></pre><p> 會變成這樣:</p><pre> some text</pre><p> 我的 MYSQL 版本是 15.1。</p></div></div> 獲取基於KeyWords的Facebook頁面URls 如何刪除所有div標簽,而不刪除其內容? (使用contenteditable =“ true”,HTML5) 如何消除潛力 <p> 通過PHP將字符串中的URL括起來嗎? 從字符串php正則表達式中刪除所有div標簽? 刪除除div類外的所有html標簽和內容 如何刪除PHP中帶有文本的所有標簽
 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM