Resource icon

Post Content Find / Replace 1.0.0

No permission to download
A note: please don't use [quote] tags, please use code tags so they preserve whatever you post, otherwise using quotes can cause problems in communication when passing code back and forth.



Also I need a better description of what it is you are showing me in replacement text. What you have shown there is the second subpattern


the replacement (Which I put single quotes instead of double accidentally) should include at least this much

[URL="\1"]\2[/URL]



...says to put the first captured subpattern after the = sign inside the first set of brackets, and put the second captured subpattern in between the two sets of brackets




<a class="postlink-local" href="http://test.com/viewtopic.php?f=25&t=265" onclick="window.open(this.href);return false;">viewtopic.php?f=25&t=265</a>

should become

[url="http://test.com/viewtopic.php?f=25&t=265"]viewtopic.php?f=25&t=265[url]
 
A note: please don't use [quote] tags, please use code tags so they preserve whatever you post, otherwise using quotes can cause problems in communication when passing code back and forth.

Ok, sorry. New here and thank you for that!


Also I need a better description of what it is you are showing me in replacement text. What you have shown there is the second subpattern


the replacement (Which I put single quotes instead of double accidentally) should include at least this much

[URL="\1"]\2[/URL]



...says to put the first captured subpattern after the = sign inside the first set of brackets, and put the second captured subpattern in between the two sets of brackets




<a class="postlink-local" href="http://test.com/viewtopic.php?f=25&t=265" onclick="window.open(this.href);return false;">viewtopic.php?f=25&t=265</a>

should become

[url="http://test.com/viewtopic.php?f=25&t=265"]viewtopic.php?f=25&t=265[url]
Ooh, sorry, really don't understand much of these now. Is it ok? Can I save this?

I've just put your instructions inside and click Proceed. Then I've pasted you what I get.

Or maybe I'll send you some examples again so you can write me instructions again.

Here you are.

<a class="postlink-local" href="http://forum.test.com/viewtopic.php?f=25&t=265" onclick="window.open(this.href);return false;">Something</a>

<a class="postlink-local" href="http://forum.test.com/viewforum.php?f=24" onclick="window.open(this.href);return false;">Something1</a>

Oh, and all those links are redirected now to my new board (if it has something to do with it).
 
Ok, sorry. New here and thank you for that!



Ooh, sorry, really don't understand much of these now. Is it ok? Can I save this?

I've just put your instructions inside and click Proceed. Then I've pasted you what I get.

Or maybe I'll send you some examples again so you can write me instructions again.

Here you are.

<a class="postlink-local" href="http://forum.test.com/viewtopic.php?f=25&t=265" onclick="window.open(this.href);return false;">Something</a>

<a class="postlink-local" href="http://forum.test.com/viewforum.php?f=24" onclick="window.open(this.href);return false;">Something1</a>

Oh, and all those links are redirected now to my new board (if it has something to do with it).

If you have links redirected it makes it easier, when you want to manually rewrite a link you need to do a lot of extra expressions and replacement, in your case if they are redirected the old links are directed to the new links when clicked so changing them should not be needed at all and again in your case you should just need to add the url tags.



I just tested the original expression against the following links.


<a class="postlink-local" href="http://test.com" onclick="window.open(this.href);return false;">Test</a>

<a class="postlink-local" href="http://test.com/viewtopic.php?f=25&t=265" onclick="window.open(this.href);return false;">viewtopic.php?f=25&t=265</a>

<a class="postlink-local" href="http://forum.test.com/viewtopic.php?f=25&t=265" onclick="window.open(this.href);return false;">viewtopic.php?f=25&t=265</a>

<a class="postlink-local" href="http://forum.test.com/viewforum.php?f=24" onclick="window.open(this.href);return false;">viewforum.php?f=24</a>



The expression seems to catch everything on my end.
PCRT.webp


So from my testing this will work if you copy and paste everything correctly


Quick Find:
Code:
<a class="postlink

Regular expression:
Code:
#<a\sclass\=\"postlink\-local\"\shref\=\"([^<\"]+)\"\sonclick\=\"window\.open\(this\.href\)\;return\sfalse\;\"\>([^<\<]+)<\/a>#siu

Replacement String:
Code:
[URL="\1"]\2[/URL]


If you do this and the replacements shown look good you can save...but IMPORTANT!!! If you don't know what you are doing when it comes to stuff using regex, please do this on a testbed first because regex is very powerful and you could muck up your posts really good with it if you do the wrong thing.
 
Give me an example of some that it didn't catch and I can see if a second expression will catch the rest that the first missed.
 
It's hard to say, because it's just a word marked as link. But when I click on it it won't find the right topic or post.

Nevemind, it's ok for important posts.
 
Oh, sorry, already edit this post where that link was. If I found something similiar, I'll let you know.
 
Oh, sorry, already edit this post where that link was. If I found something similiar, I'll let you know.

(response to Convo)

This should catch the rest of those links.

Quick Find:
Code:
<a class="postlink

Regular expression:
Code:
#<a\sclass\=\"postlink\"\shref\=\"([^<\"]+)\"\sonclick\=\"window\.open\(this\.href\)\;return\sfalse\;\"\>([^<\<]+)<\/a>#siu

Replacement String:
Code:
[URL="\1"]\2[/URL]
 
(response to Convo)

This should catch the rest of those links.

Quick Find:
Code:
<a class="postlink

Regular expression:
Code:
#<a\sclass\=\"postlink\"\shref\=\"([^<\"]+)\"\sonclick\=\"window\.open\(this\.href\)\;return\sfalse\;\"\>([^<\<]+)<\/a>#siu

Replacement String:
Code:
[URL="\1"]\2[/URL]
Ok, I'll try it.
 
Hello,

I'm doing a vb -> xf convert and i always get crushed on regular expressions. I'm trying to convert the following bbcode:
Code:
[video=youtube;YOUTUBEID]http://www.youtube.com/watch?v=YOUTUBEID&SOMEJUNK[/video]

to the standard media bbcode:
Code:
[media=youtube]YOUTUBEID[/media]

Can someone who doesn't mind regular expressions help me on this one? :) Also, I'm not too good with mysql regex REPLACES as well!

THanks!




Quick Find:
Code:
[video=youtube

Regular expression:
Code:
#\[video\=(youtube)\;([a-z0-9-_]+)\][^\[]+\[\/video\]#siu

Replacement String:
Code:
[media=\1]\2[/media]
 
Last edited:
I've made a lot of replaces on xf 1.2, but now on 1.2.1 it doesn't work. Always the error appears, that the memory limit is reached. That can not be, the current memory limit on our test server is 1024MB!
 
Need some help with Find / Replace after final import from vB into XF

After I have successfully imported my vB forum into XF I have some strange BBCode snippets in some posts. As per the user the text was originally formatted with Arial font.

Now there are the following snippets all over the posts:

[FONT=&amp].....[/FONT]

There are several different characters between those two tags, digits, letters, full sentences and even whole paragraphs.

Now I have two options:
1. To remove these BBCode snippets completely or
2. change [FONT=&amp] back into [FONT=ARIAL]

Any idea how to realize this?
 
Try this...


Quick Find:
Code:
[FONT=&amp]

Regular expression:
Code:
#\[font\=\&amp\]#siu

Replacement String:
Code:
[FONT=ARIAL]
 
Top Bottom