Remove different links from MySQL table - mysql

How i could remove different links i have in a MySQL field in many rows? I couldn't find a query for that.
I don't have much experience with MySQL, the ideal solutions would be something that begins with something and ends with something.
Example:
On table 'ads' i have a field called 'description' that has the ad description text. I have links inside the descriptions and i want to remove them all, but those links have different urls from ads to ads. I don't want to delete the text of the link, just the link itself <a class="something" href="http://someurl.com">Link text</a>

Please give a better explanation of your problem and a sample of code.
Although, if i'm right on what you want to achieve, you might need something like this below.
Example:
UPDATE ads SET description=REPLACE(description,'whatYouWantToDelete','')
The above will remove everything in your column that contains the string foo.
UPDATE:
These might be helpful.
Remove HTML tags from record
Removing links from posts in wordpress using query

Related

Xpath with wildcards between id and divs?

I try to enter data in a table using Robot Framework. The table has an ID, but it changes every time I load the page (it is some kind of UUID) so I can't use it as "anchor" for my xpath. However there is a heading for this table that seems reasonable to start with that has a fixed ID. Inbetween the heading and the table there are a couple of divs. So something like this (some mix of pseudo code and what I get when I copy selector and xpath in Chrome) to get to the first cell in the first line of the table:
//*[#id="heading"] (a bunch of divs) /*[#id="random string of letters"]/div[3]/div/div/div[2]
I would like to write an xpath that looked something like this
//*[#id="heading"] [wildcard for the random ID and divs] /div[3]/div/div/div[2]
How do I write this?
Thank you.
If only one element inside the "header" contains an id attribute you could use
//*[#id="heading"]//*[#id]/div[3]/div/div/div[2]
If there are more than one element with id attribute you need something more, eg if it contains a certain tag
//*[#id="heading"]//*[contains(#id, "tag")]/div[3]/div/div/div[2]
or (if using xpath 2.0) and only this #id contains an uuid within the heading
//*[#id="heading"]//*[matches(#id,"[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")]/div[3]/div/div/div[2]
Otherways you will have to try to find something unique (within the context of "heading") to start the div[3]/div/div/div[2] search (if you are lucky div[3]/div/div/div[2] is unique enough.

SQL query to find columns with more than one string "a href" in them

I'm organizing articles in a big database and I face a problem - I need to find all articles with two or more links in them.
Every link is HTML link and has form .... How do I SELECT from article database with all links that a have at least two a href in them?
I was taught how to select one a href but two?...
SELECT * FROM `Articles5` WHERE
content LIKE "%a href%"
How to double this?
Had you tried using your own code but twice?
SELECT * FROM `Articles5` WHERE
content LIKE "%a href%a href%"
At first you can get all Articless WHERE content LIKE "%a href%" and put in temporary table. Then replace this value and find "a href" once more.
P.S For this purpose I advice you to use FullTextSearch

MySQL removing HTML hyperlinks while keeping name of link

So I'm trying to do the following:
A column in my table contains a bunch of text, amongst which is --
<a href="random.website.com>Text I want to keep</a>
which I want to change to:
Text I want to keep
Do also note that "random.website.com" is basically unique for each item, i.e.: it contains a different link for each item.
I am aware that there is a third party UDF called REGEXP_REPLACE but this is not available for me to use.
Is there any other to accomplish this? Appreciate any help of course.
Regards

Find and replace a lot of <a> tags, but the url are different? Is there some way to do it?

I have a page that I need to fix..
There are thousands of <a> tags like <a href="kl1j23l123l12j3"> that I need to get rid off, but the problem is that each <a> tag has a different url in them (href attribute). So, I am wondering if there is some advanced way to get rid of the whole anchor/link but keep the link-text, as that would save me a whole lot of time.
Example
Input : StackOverflow.com
Output: StackOverflow.com
Thanks.
Maybe this is a solution using JavaScript and jQuery. It also can be tweaked to only get the values of links that do not start with http. I wasn't quite sure whether this is relevant according to the links in the question.
// get all links within the document
​var links = $('a');
// simply get all link texts
var x = links.text();​​​​​​
// or just get all links that are like 'kl1j23l123l12j3' as they don't start with 'http'
var x = links.filter('[href^=http]').text();
Here's a demo: http://jsfiddle.net/rg3ET/
Instead of applying them all together into one variable ("x") you could of course loop through them and output them individual.
The following would work under the assumption that each anchor tag is on its own line.
Example:
asdf
<div>
</div>
asdf2
Notepad++ has a regex find and replace feature, which may work for your need.
Replace all </a> tags with nothing
Use a regex to find all <a href="anything"> and replace with nothing.
The following image shows what I did for step 2. You can see that I used a regex of <a .*>. For this to work properly, there should only be one > character per line. Otherwise, the regex will make the longest possible match, possibly including a bunch of other tags. This is why I said the procedure would only work for anchor tags that are on their own lines.
In case you can't see the image (again, this only works:
From Notepad++ menu: Search > Replace
Select Regular expression
In Find what box, put <a .*>
Click Replace All

How can I hide/remove/disable "forums views" in vbulletin?

anyone have an idea how to do this.
i need to get rid of forum views either by hide, delete, disable or any other way.
I assume you mean THREAD views in the text below:
Do a template search for $thread[views], and there should be a template called threadbit. If you want to quickly and easily obscure the views just delete $thread[views] and replace with or asterisks, or whatever you'd like.
If you want to remove the whole <td> it becomes more complicated. First you remove that <td>, and then in FORUMDISPLAY template you have to remove the <td> that contains $vbphrase[views] (do a search for it if you can't find it).
But I believe there may be some issue with removing that entire column, and any of the hardcoded colspan attributes among the templates. If so then you would have to reduce the colspan number by one. I'm not sure about the colspan part, it's been a long time since I edited the FORUMDISPLAY and threadbit templates.
Also, you will need to remove the Views from another location in the threadbit template:
title="<phrase 1="$thread[replycount]" 2="$thread[views]"
This shows up when you hover on top of the Last Post column. Just delete $thread[views] and it will show up blank.
i need 50 points to reply, sorry for keep using answer.
i was thinking of going 1 step futher and swapping the word hidden for a picture?
I used the word hidden just as a test to see if it would work which it does