Resource icon

Post Content Find / Replace 2.0.1

No permission to download
Relating to the following discussion:

I'm trying to remove these remnant viglinks that still exist long after I've uninstalled the VigLink add on. This post explains why they're still showing up:

In any event, the VigLinks look like this:
Code:
https://redirect.viglink.com/?format=go&jsonp=vglnk_172485894788610&key=b617ddd562e3b6e9c916999f0745de59&libId=m0e0hccj01000b3h000ULqfqvkczaz3jp&loc=https%3A%2F%2Fpontiacforum.com%2Fpontiac%2Fthreads%2F1998-2002-y87-firebird-identification.39586%2F%23post-117590&v=1&opt=true&out=http%3A%2F%2Fi.viglink.com%2F%3Fkey%3D2ecd8bc9fcc7034251aad35a31b16337%26insertId%3Defd9b8a17188ef61%26type%3DM%26exp%3D60%253ACI1C55A%253A1%26libId%3Dk8agt6is01000b3w000MAbwxxrs7l%26loc%3Dhttps%253A%252F%252Fcamaroforums.com%252Fforum%252F93-02-v6-tech-14%252F3800-performance-package-y87-40820%252F%26v%3D1%26iid%3Defd9b8a17188ef61%26opt%3Dtrue%26out%3Dhttp%253A%252F%252Fwww.ebay.com%252Fsch%252FeBay-Motors-%252F6000%252Fi.html%253F_from%253DR40%2526_nkw%253Drear%252Bbrakes%26ref%3Dhttps%253A%252F%252Fwww.google.com%252F%26title%3D3800%2520performance%2520package%2520(y87)%2520-%2520Camaro%2520Forums%2520-%2520Chevy%2520Camaro%2520Enthusiast%2520Forum%26txt%3D%253Cspan%253Erear%2520%253C%252Fspan%253E%253Cspan%253Ebrakes%253C%252Fspan%253E&title=(68)%201998%202002%20Y87%20Firebird%20identification%20%7C%20Pontiac%20Owners%20Group&txt=rear%20brakes

I'm trying to figure this out myself but am not having any luck. What should I be using for the items below?

Quick Find:
Regular Expression:
Replacement String:

Whatever I'm trying gives me the following error:

ErrorException: [E_WARNING] preg_match_all(): Delimiter must not be alphanumeric, backslash, or NUL in src/addons/XFPR/Admin/Controller/PostReplace.php at line 41

XF::handlePhpError()
preg_match_all() in src/addons/XFPR/Admin/Controller/PostReplace.php at line 41
XFPR\Admin\Controller\PostReplace->actionReplace() in src/XF/Mvc/Dispatcher.php at line 352
XF\Mvc\Dispatcher->dispatchClass() in src/XF/Mvc/Dispatcher.php at line 258
XF\Mvc\Dispatcher->dispatchFromMatch() in src/XF/Mvc/Dispatcher.php at line 115
XF\Mvc\Dispatcher->dispatchLoop() in src/XF/Mvc/Dispatcher.php at line 57
XF\Mvc\Dispatcher->run() in src/XF/App.php at line 2485
XF\App->run() in src/XF.php at line 524
XF::runApp() in admin.php at line 13
You could do it with a query on the dB directly, do you want to null the links at all?
 
I'd like to delete all the links. I guess that's the same as nullifying them...

Maybe something like?

Code:
UPDATE xf_post
SET message = REGEXP_REPLACE(
    message,
    '\\[URL\\]https?:\\/\\/.*?viglink\\.com\\/.*?\\[\\/URL\\]',
    '[URL]replacement[/URL]'
);

But the issue is that the URL's need to be inside the URL code or else , yeah. This may or may not work, worth a try but does require direct DB access. I would try it on a backup db and simulate the results.

Also you'll need to run this query to bypass limitations;

Code:
SET GLOBAL regexp_time_limit=0;
 
Maybe something like?

Code:
UPDATE xf_post
SET message = REGEXP_REPLACE(
    message,
    '\\[URL\\]https?:\\/\\/.*?viglink\\.com\\/.*?\\[\\/URL\\]',
    '[URL]replacement[/URL]'
);

But the issue is that the URL's need to be inside the URL code or else , yeah. This may or may not work, worth a try but does require direct DB access. I would try it on a backup db and simulate the results.

Also you'll need to run this query to bypass limitations;

Code:
SET GLOBAL regexp_time_limit=0;
Thank you, I assume this would work but I'm going to hope and hold out for more input on the find and replace add-on as my preference is to avoid messing around with the database manually...
 
Thank you, I assume this would work but I'm going to hope and hold out for more input on the find and replace add-on as my preference is to avoid messing around with the database manually...
If you use phpmyadmin you can simulate the query on your test dB and it will give you results, if its targetting the correct strings, try it. No harm on a test dB.
 
If you use phpmyadmin you can simulate the query on your test dB and it will give you results, if its targetting the correct strings, try it. No harm on a test dB.
My first issue here is that I've never had the need for a test database until now...
 
How can i replace this

example
/ example /
" example "

The problem here is that we replace " example " <- space before and after
with "example" because the spaces for the replacement are removed.
 
Hello, I need to remove some color bbcodes applied to text on the forum posts.
Curent format:

Code:
[SIZE=13px][COLOR=rgb(138, 138, 138)][SIZE=4][B]LOCALITATEA[/B]: Vorona (județul Botosani);[/SIZE][/COLOR][/SIZE]

the result should be like this:
Code:
[SIZE=13px][SIZE=4][B]LOCALITATEA[/B]: Vorona (județul Botosani);[/SIZE][/SIZE]

Another example:
Code:
[SIZE=13px][COLOR=rgb(138, 138, 138)][SIZE=4][B][COLOR=rgb(52, 152, 219)]Hobby [/COLOR][/B]- poate participa orice jucător cu media intre 2 şi 9,99.[/SIZE][/COLOR][/SIZE]

expected result
Code:
[SIZE=13px][SIZE=4][B][COLOR=rgb(52, 152, 219)]Hobby [/COLOR][/B]- poate participa orice jucător cu media intre 2 şi 9,99.[/SIZE][/SIZE]
 
For first part: \[COLOR=rgb\([^)]+\)\]((?:(?!\[COLOR=).)*?)
For second part: \[\/COLOR\]

You should replace them with nothing. It should resolve your issue. If it's not work provide some info about issue, I'll help again
🙏


Don't forget, first you should try first Regex and replace all of them with nothing. Then you should use second Regex.
 
For first part: \[COLOR=rgb\([^)]+\)\]((?:(?!\[COLOR=).)*?)
For second part: \[\/COLOR\]

You should replace them with nothing. It should resolve your issue. If it's not work provide some info about issue, I'll help again
🙏


Don't forget, first you should try first Regex and replace all of them with nothing. Then you should use second Regex.
I just want to remove this color, not all colors:
Code:
[COLOR=rgb(138, 138, 138)]

If i use SQL to replace with nothing I will have to deal with the remaining
Code:
[/COLOR]
 
It would be nice if something like this would automatically fix @user in posts when a user changes their name. Anything like that exist?
Yes, that should be fixed. The username really should be pulled from the user ID, vs. hard-coding it into the quote. It might require another database query, but I'd take that over having to go through a bunch of name changes on a forum with 35 million posts, and hope that it was done correctly.
 
Back
Top Bottom