Resource icon

Post Content Find / Replace 1.0.0

No permission to download
Hi,
I've absolutely no knowledge in regex and like to ask whether it's possible to replace strings like:


Code:
http://www.myboard.org/technikforum/26307-besten-s-w-fotos-generieren-bearbeiten.html

replace with:
http://www.myboard.org/threads/wie-am-besten-s-w-fotos-generieren-und-bearbeiten.26307/


http://www.myboard.org/stelle/33578-hoffentlich-endlich-richtig-lissabon-ola.html

replace with:
http://www.myboard.org/threads/jetzt-hoffentlich-endlich-richtig-in-lissabon-ola.33578/


http://www.myboard.org/fragen-forum/30900-bestimmte-threads.html

replace with:
http://www.myboard.org/threads/kann-bestimmte-threads-nicht-finden.30900/

...

The're some differences:
- technikforum, stelle, fragen-forum and lots of others (but different numbers of chars!), ...
- that the ID has moved from, beginning to end and
- the're additional words like "wie-am-", and "jetzt-", and "kann-" and maybe lot of others.

Can I use this add-on and how should the regex look like ... ;) ?
Kai
 
Hi,
I've absolutely no knowledge in regex and like to ask whether it's possible to replace strings like:


Code:
http://www.myboard.org/technikforum/26307-besten-s-w-fotos-generieren-bearbeiten.html

replace with:
http://www.myboard.org/threads/wie-am-besten-s-w-fotos-generieren-und-bearbeiten.26307/


http://www.myboard.org/stelle/33578-hoffentlich-endlich-richtig-lissabon-ola.html

replace with:
http://www.myboard.org/threads/jetzt-hoffentlich-endlich-richtig-in-lissabon-ola.33578/


http://www.myboard.org/fragen-forum/30900-bestimmte-threads.html

replace with:
http://www.myboard.org/threads/kann-bestimmte-threads-nicht-finden.30900/

...

The're some differences:
- technikforum, stelle, fragen-forum and lots of others (but different numbers of chars!), ...
- that the ID has moved from, beginning to end and
- the're additional words like "wie-am-", and "jetzt-", and "kann-" and maybe lot of others.

Can I use this add-on and how should the regex look like ... ;) ?
Kai

You can't do these exact replacements with regex. The best that can be done is to convert them into plain thread_id links (e.g. http://www.myboard.org/threads/30900/ ).

But this isn't really necessary. If you implement redirects for old threads (which you should do anyways) then those old links will be automatically redirected without having to correct the link itself.
 
Thx Jake, finally I understood the idea behind your redirect scripts ... :rolleyes: It tooks a while ... but I guess the're an few other things which I would like to change with this add-on here. Later ...
 
I got this working on a couple of mods but need help with reg expressions to replace these bbcodes

Code:
[box-left]
<o:p>
(this one is actually a smiley from VB4, need it removed not replaced).

also need to replace this:

[SUP]12 [/SUP]
 
Last edited:
Imported from VB4 and lots of old smilies now show as plain text

Like,

Code:
:cry:

How would I properly find/replace this with no text, so essentially just remove them? I'm sorry but I don't know regular expression stuff.
 
Imported from VB4 and lots of old smilies now show as plain text

Like,

Code:
:cry:

How would I properly find/replace this with no text, so essentially just remove them? I'm sorry but I don't know regular expression stuff.

Note that first back up.

Code:
UPDATE xf_post SET message = REPLACE(message, 'OLDTEXT', 'NEWTEXT');

So... If you want to remove it;

Code:
UPDATE xf_post SET message = REPLACE(message, ':cry:', '');

It's possible to remove or replace all that smilie text via SQL Query.
 
Imported from VB4 and lots of old smilies now show as plain text

Like,

Code:
:cry:

How would I properly find/replace this with no text, so essentially just remove them? I'm sorry but I don't know regular expression stuff.

Note that first back up.

Code:
UPDATE xf_post SET message = REPLACE(message, 'OLDTEXT', 'NEWTEXT');

So... If you want to remove it;

Code:
UPDATE xf_post SET message = REPLACE(message, ':cry:', '');

It's possible to remove or replace all that smilie text via SQL Query.


It's not necessarily the best solution simply because the only reason to get rid of it is that you say it doesn't work but :cry: is a valid smiley if you want it to be and the default sprite includes it. The only thing you need to do is create a new smiley setup like the following below.

createNewSmiley.webp
 
It's not necessarily the best solution simply because the only reason to get rid of it is that you say it doesn't work but :cry: is a valid smiley if you want it to be and the default sprite includes it. The only thing you need to do is create a new smiley setup like the following below.

View attachment 93900

Yes that is correct.

I forget it, sorry for that.
 
Yes that is correct.

I forget it, sorry for that.
Don't be sorry, two nuts on one screw is not exactly a disaster, but if replacements are made like this where stuff is removed and there is no index stored of the changes it could be anywhere from slight to quite impossible to reverse. (this is more of a note to people seeking the replacements, but we all take and keep db backups anyways, right?).

In this case it was a crying smiley, not exactly the hugest deal.
 
Hi there!

For some reason, I've got un-bbcoded URLs and I also have properly bbcode enclosed URLs.

A sample xf_posts record may look like this:

Code:
Hello. Here are some links.

First link http://www.somesite.com
Second link: [URL]http://www.somesite.com[/URL]
Third link: [URL=http://www.somesite.com]Hello XF[/URL]


Goodbye.

I would need to enclose the first link in the example above within BBCODE as well.

I've been trying to construct an expression this morning using Positive and Negative Lookbehinds and all kind of stuff but I've failed. Can You guys help me?
 
Hi there!

For some reason, I've got un-bbcoded URLs and I also have properly bbcode enclosed URLs.

A sample xf_posts record may look like this:

Code:
Hello. Here are some links.

First link http://www.somesite.com
Second link: [URL]http://www.somesite.com[/URL]
Third link: [URL=http://www.somesite.com]Hello XF[/URL]


Goodbye.

I would need to enclose the first link in the example above within BBCODE as well.

I've been trying to construct an expression this morning using Positive and Negative Lookbehinds and all kind of stuff but I've failed. Can You guys help me?

I have a script for this, but I would insist on running it myself since it requires working with the code a bit. Send me a PM with FTP access and I can fix those links for you.
 
I have a script for this, but I would insist on running it myself since it requires working with the code a bit. Send me a PM with FTP access and I can fix those links for you.

Thanks @Jake Bunce .

I did check how severe the problem was by running the following sql statement
Code:
SELECT message FROM `xf_post` where message like "%http://%" and message not like "%]http://%" and message not like "%=http://%" and message not like "%='http://%"

It turned out I have only 64 matching records with malformed URLs so I might as well edit them manually in phpMyAdmin. However I like to thank You for your kind offer to help me.
 
I got this working on a couple of mods but need help with reg expressions to replace these bbcodes

Code:
[box-left]
<o:p>
(this one is actually a smiley from VB4, need it removed not replaced).

also need to replace this:

[SUP]12 [/SUP]


The following expression did the trick for me... (y)

string.webp
 
No, the site you are linking to has no pattern associate with that link, that is a unique item number from their product offerings.

While there are some things you can do with regex which are not standard things people normally do (changing case and such is possible in some flavors of regex) for this particular example no there is no better way really as replacing a single link with regex is kinda already overkill unless you can read and write regex like it was English though if you are using this addon to find the post in the first place it's perfectly understandable to just go ahead and replace it right there.
 
Top Bottom