On Tuesday, January 28, 2020 at 8:31:38 AM UTC-8, Jefferis Peterson wrote: > > I am dealing with old hacked sites in Wordpress where there are injection > spam links on images. Also, need this for standard html sites. > > I have access to the database and would like to remove links that look > like this: > > > <a style="text-decoration:none" href="/ansaid-retail-cost">.</a> >> >> > > Now the link varies inside the href and it might be for cialas or any > product, but the rest doesn't vary. I want to remove the entire LINK, so > the result is a single space. > > > I don't know regex, so I would appreciate the help. I've tried online > regex generators but they don't seem to be working. > > > In this case, the html link is attached to an image caption in the > database. However, finding that type of string in the database is what I > need to replace by removing it entirely. If I find and replace just the > source code <a style="text-decoration:none" href=" portion it will leave a > lot of empty tags or erase things I don't want it to. >
Given your sample link you want to find and replace with a space, the following regular expression will find the hacking links: <a style="text-decoration:none" href="[^"]*">\.<\/a> and for the replacement: Note: the replacement is a space character. The [^"]* matches anything that isn't a " character and will match any string (including no string) between the quotes in that position regardless whether the string is a valid URL format. If you need to be more specific or careful about what is getting matched in the quoted string, post some more example patterns of what you want to match along with pattern strings you specifically don't want matched. For a test sample string: test text text preceeding <a style="text-decoration:none" href="/ansaid-retail-cost">.</a> text succeeding <a style="text-decoration:none" href="/ansaid-retail-cost">.</a> the global find and replace will result in: test text text preceeding text succeeding I suggest doing extensive testing on sample database copies to ensure you're getting the results you want. BBEdit's find and replace can really change a whole lot in a short time so you want to make sure you aren't going to regret it before clicking replace all. -- This is the BBEdit Talk public discussion group. If you have a feature request or need technical support, please email "[email protected]" rather than posting here. Follow @bbedit on Twitter: <https://twitter.com/bbedit> --- You received this message because you are subscribed to the Google Groups "BBEdit Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/bbedit/8bba3f79-5f5e-4ca2-8e6a-c1435cefaea6%40googlegroups.com.
