Resource icon

Post Content Find / Replace 1.0.0

No permission to download
@Kier any plans to make this super popular add-on available for XF 2.x as well in the form of an add-on or built-in feature? If yes, please consider supporting batch mode because it fails to work if the number of matched items is large.
 
I need to replace a block with multiple lines of code.
Is it possible to do that with this addon.
To be clear, do all these posts have this code inside code bbcode blocks?

My regex (if it works) should find any code block containing "var SymRealOnLoad;" and you can set it to "". You don't need to create a regex with the entire chunk of code in it. I assume there are no other code block with that string inside.
 
@Alfa1 Oh, I see. The regex below is the first few lines, then some junk and the last few lines.

/<!--\s+var SymRealOnLoad;\s+var SymReal;[\s\S]+SymRealOnLoad = window.onload;\s+window.onload\s+=\s+SymOnLoad;\s+\/\/-->/

Give that a try
 
I would also like to remove all use of FONT bbcode. Including variations like this:
Code:
[FONT=Verdana, Lucida, Arial, Helvetica, sans-serif]
Or whatever font people have used.
 
mhm. I keep getting time outs as there are 13k results. So I will need to split it up. Attached are the font codes I have.

With the previous replacement I got the error that I needed to fill in a replacement text. But I just want to remove it. Is there anything I can fill in the replacement field to avoid that?
 

Attachments

You can break the job up using more precise matching.

[^\]]+? will match any string of characters where each character is anything but a closing bracket

So you can break up the job by specifying the first character in the parameter. To get all the ones that start with a quote mark use this

/\[font="[^\]]+?\]/i

Now get ones without quotes that start with a to f

/\[font=[a-f]{1}[^\]]+?\]/i

then g to m

/\[font=[g-m]{1}[^\]]+?\]/i

etc, etc. As for the closing tags I 'm not sure what to do. Maybe let it run until it times out and then go again.
 
Something's wrong here. How many posts total do you have? Could there really be that many posts with font tags?
Yes, easily. Last post ID is upward of 1.9 million. And my members love to fiddle around. Especially female members with pink text in pretty fonts.

These ones goes wrong:
/\[font="[^\]]+?\]/i
/\[font=[a-f]{1}[^\]]+?\]/i
Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 11038520 bytes)

I was able to do a full search on this one, but not save it:
/\[font=[^\]]+?\]/i
So I am not sure why the full search would work better than the partial search. 250MB should be more than enough.
 
The more specific searches are more complicated and require more resources. It still has to go through every post to check and checking each one takes more. It's one thing to get a regex to work, another to get it to work efficiently, and on that last matter I'm not of much help. Too bad the product isn't designed to do things in batches.

I'm sure there are better regex people than I, if only you could get them interested in this problem.

You could try going through each letter of the alphabet with or without the initial quote. It might be a simpler search

/\[font="?a[^\]]+?\]/i

/\[font="?b[^\]]+?\]/i


/\[font="?c[^\]]+?\]/i
 
mhm. I keep getting time outs as there are 13k results. So I will need to split it up. Attached are the font codes I have.

With the previous replacement I got the error that I needed to fill in a replacement text. But I just want to remove it. Is there anything I can fill in the replacement field to avoid that?

You can break the job up using more precise matching.

In some cases sure but not all. Jake Bunce posted a fix for this a long time ago which allows you to batch things without accounting for more unique signatures with your regex.

If you are comfortable making a few edits you can follow this post and set your offsets in the script,
https://xenforo.com/community/threads/import-from-ipb-3-2-posts-not-parsed-at-all.39577/#post-435226

If you would like to play with those offsets and not keep editing the script every time you would like to change offsets you can follow this edit which is the same thing except once done the options will be added to the addon ending the need for further edits,
https://xenforo.com/community/threads/post-content-find-replace.6548/page-53#post-1019961
 
Code:
#(\[img]https://www\.my\-forum\.com)/forum/attachment\.php\?attachmentid=([0-9]+)&d=([0-9]+)(\[/i m g])#siu

looks like it wants to match something like

Code:
[IMG]https://www.my-forum.com/forum/attachment.php?attachmentid=123&d=222[/img]

What's that "d=(some number)" do? Do you need it for anything? Find an oldvB link and see if attachmentid and d are the same number
 
Last edited:
Back
Top Bottom