Resource icon

Post Content Find / Replace 1.0.0

No permission to download
Hello. We have successfully installed this addon (just extracted the archive and moved the PostReplace directory under library/, then loaded the xml file). However whenever we try to use it we either receive no data back, or it just seems to hang, or our other admin said he once received just "1" as response. Initially I received an php error about that the script was unable to allocate memory so I raised the limit, since then there is no error and no data coming back. Any ideas? XenForo 1.4.2, php 5.4.33, apache with mod_php
Try following these instructions to bring in batch processing and then run whatever regular expression you are attempting again and see what it nets you.
https://xenforo.com/community/threads/import-from-ipb-3-2-posts-not-parsed-at-all.39577/#post-435226
 
Would it be possible to run something like this regularly? For example, I am looking to replace a particular piece of content that is coming over in an RSS feed on a daily basis.
 
for just a record
Code:
UPDATE xf_post SET message = REPLACE(message, '\\', '"')
the above query replaces \ to "
 
Not quite working as expected. I want to replace

Code:
[/QUOTE']

But the matched text is missing the square brackets. How would I get this to include the brackets (which i thought can be part of a regular expression? Thanks

postreplace.webp
 
You need delimiters in your expression because they tell the regex engine the start and stop point, the way you setup your expression it is using the [ and ] as starting and stopping points, also when you want to match a literal [ you need to escape it so that regex doesn't think you are specifying a character class (like a-z which is [a-z]) which you would do like this \[.

You expression to match
[/quote']​
would be
#\[/quote']#siu​
 
You need delimiters in your expression because they tell the regex engine the start and stop point, the way you setup your expression it is using the [ and ] as starting and stopping points, also when you want to match a literal [ you need to escape it so that regex doesn't think you are specifying a character class (like a-z which is [a-z]) which you would do like this \[.

You expression to match
[/quote']​
would be
#\[/quote']#siu​


Thanks, I was trying to work out how to do that, seems incredibly complicated.
 
Thanks, I was trying to work out how to do that, seems incredibly complicated.
It can be when you first start out with regex and then it get's pretty easy for the simple stuff like this, but as match subjects get more complex they become more time consuming than anything .

If I had to explain my view on the matter it would come out something like: when you write code, you do so to display something or do a specific function but when you write complex regex, you are doing it to match all things in a pattern that may or may not exist yet so you kind of have to work out all the possible permutations of similar text strings which could need to matched down the road and that takes the ability to use logic on things you can't see but that logic must be something you can express with regex.

In any language I have messed with, no matter the syntax, you are trying to start at point A and make it to point C by doing everything you need to in B and you can plan in your head the same way you could put it down when writing code which makes everything easy to think of using forward thinking, but when matching large highly variable subjects in regex it is almost like you are starting at C trying to hunt down A while accounting for everything in B even though there are 50 possible points where C could be and B has to get C to A no matter where C started.

Simple strings can become very easy to manage yourself once you learn regex, but the longer more complex string become insanely convoluted even if you like regex more than you should (though nothing I have seen in programming seems as useful or powerful while being available in as many languages as it is so it is kind of worth learning if you like to tinker or plan on becoming a full time programmer).


_____________________________


What would I use to replace dead links like this to this (dead link removed)
examples:
http://www.sublymerecords.com/Phil/Longest.mp3
http://www.sublymerecords.com/ROPics/Manang.mp3
http://www.sublymerecords.com/samples/blumspot.mp3

(dead link removed)


You can't remove dead links with this tool (unless you know that all links from DOMAIN.com are now dead and you remove dead links per dead domain , one domain at a time.)

I made a script which does check all links(and images) and remove dead entries but as far as this addon goes detecting dead links/images is way beyond the scope of this addon's purpose.

Also the first link you listed...is not a link to that dead domain name (it's a link to your own forum with a text placeholder for the link which looks like the dead site) so I assume that is NOT a link you would wish to remove because the link itself is not dead.

Quick Find:
Code:
sublymerecords

Regular expression:
Code:
#\[(url)(?:]|=')http://www\.sublymerecords\.com[^'\[]+(?:'](?:.*?(?!\[/\1]?).)(?:\[/\1])|\[/\1])#siu

Replacement String:
Code:
(dead link removed)
 
Last edited:
Hmm, I'm trying to learn about regex but find it baffling

I want to replace the text: dead link

I found a tutorial saying to replace the space with \s so I put in dead\s link but then I get this error

preg_match_all(): Delimiter must not be alphanumeric or backslash

I also have a phrase in normal rounded brackets, how would I deal with those?

e.g (Dead link removed)

Thanks
 
Hmm, I'm trying to learn about regex but find it baffling

I want to replace the text: dead link

I found a tutorial saying to replace the space with \s so I put in dead\s link but then I get this error

preg_match_all(): Delimiter must not be alphanumeric or backslash

I also have a phrase in normal rounded brackets, how would I deal with those?

e.g (Dead link removed)

Thanks

You left the space (which can also be used in this instance and is not the problem) so by having \s plus a space between dead and link you are saying 'dead THEN exactly 2 spaces THEN link'

You are also not using delimiters. dead\slink
You must always use enclose your regex in delimiters I use this ##

This is a useable example for your purposes which has been properly formatted #dead\slink#
 
I made a script which does check all links(and images) and remove dead entries but as far as this addon goes detecting dead links/images is way beyond the scope of this addon's purpose.

I wanted to remove every link to certain domains so thank you!! Its exactly want i needed. BUT, I'm interested in your removal script now! Where is it available $ etc? Thanks.
 
I wanted to remove every link to certain domains so thank you!! Its exactly want i needed. BUT, I'm interested in your removal script now! Where is it available $ etc? Thanks.
The script runs on my server currently as a private api of sorts, I recently added a bunch of more complex functionality like forked processes in queue for existing image rewriting, but I am toying with the idea of making a simple standalone script out of the base functionality (check and remove dead links and image urls). I never had planned on releasing it as it is completely independent of xf (other than modifying the db that your xf is using) but if it is something you are still interested in and don't mind uploading and executing a single php doc as like a monthly maintenance thing shoot a msg to my inbox and maybe we can work something out.
 
can anyone help with the following

need to replace XX with YY

two characters, origin and target uppercase

example:

the XX works really well

->

gets converted to

->

the YY works really well


BUT

theXX works really well

or

theXXworks really well

won't be converted

xx won't be converted either, only uppercase XX


Only those instances where XX is preceded and succeeded by a space, gets converted to YY

Help appreciated :X3:
 
I think this is simple but I'm a regex dummy.

I need to replace the domain only in all instances that match

Code:
http://www.olddomain.org/Forums/tabid/78/aft/417/Default.aspx

with

Code:
http://www.newdomain.org/Forums/tabid/78/aft/417/Default.aspx

Where the only thing that is dynamic is the "417", which is the thread ID
 
Through some trial and error, I figured this out

Quick
Code:
olddomain

Regular expression

Code:
#(http://www\.olddomain\.org)(/Forums/tabid/78/aft/.[0-9]+/Default\.aspx)#siu

Replacement String:
Code:
http://www.newdomain.org\2

But out of 170,000 + posts, that only caught 143 instances. I will have to look for more examples. It's a messy conversion that I'm working on
 
can anyone help with the following

need to replace XX with YY

two characters, origin and target uppercase

example:

the XX works really well

->

gets converted to

->

the YY works really well


BUT

theXX works really well

or

theXXworks really well

won't be converted

xx won't be converted either, only uppercase XX


Only those instances where XX is preceded and succeeded by a space, gets converted to YY

Help appreciated :X3:

Quick Find:
Code:
XX

Regular expression:
Code:
# XX #su

Replacement String (note the space before and after the YY):
Code:
YY








I think this is simple but I'm a regex dummy.

I need to replace the domain only in all instances that match

Code:
http://www.olddomain.org/Forums/tabid/78/aft/417/Default.aspx

with

Code:
http://www.newdomain.org/Forums/tabid/78/aft/417/Default.aspx
Quick Find:
Code:
olddomain

Regular expression:
Code:
#(http://www.)(olddomain\.org)(/Forums/tabid/[0-9]+/aft/[0-9]+/Default\.aspx)#siu

Replacement String:
Code:
\1newdomain.org\3
 
Last edited:
Top Bottom