Resource icon

Post Content Find / Replace 1.0.0

No permission to download
BTW: it would be really perfect to reduce the queries to a number.
Maybe you want to add a field to the addon and we start with a smaller number instead of replacing everything? (I have really a lot of post to replace things like .+ )
For now try the instructions in this post, where you see 5000 set that to whatever you are comfortable with running for batches.

https://xenforo.com/community/threads/import-from-ipb-3-2-posts-not-parsed-at-all.39577/#post-435226

Hmmm, i dont know how to get all hits.

For

Code:
[size=2]lala[/size] [size=2]huhu[/size]

I get only

Code:
lala[/size] [size=2]huhu

back. What can i do, please?
Without knowing what you want to do with you matches it is hard to say because I have no way to organize logical groups of match segments.

Are you changing to a custom format or are you trying to remove the close/open tags that connect where the first and second bbcode are both indicating equal sizes?
 
There is a lot of "****" in my old vb.
E.g:
Code:
[size=2]lala[/size]
many times in one post.
I had a regex that takes the first and the last, but then i have a lot of
Code:

So i need a regex to take (size=2)****(/size) many times and not one time.
 
Maybe i have a really big problem?

"/forum/showthread.php?p=295731#post295731"

Vbulletin could link to a post only with the postid; i dont know if xf can do this also?

The normal way seems to be threads/thread_id/#post_id=
If so i will need a php-script looking for all links with post_id only, find the thread_id and replace it like xf needs it.

Maybe this is a clean way, but more work. :)

Or is there a call for xf also with only the post_id?
 
There is a lot of "****" in my old vb.
E.g:
Code:
[size=2]lala[/size]
many times in one post.
I had a regex that takes the first and the last, but then i have a lot of
Code:

So i need a regex to take (size=2)****(/size) many times and not one time.
Right but, that does not answer the question I asked you. I understand what you are trying to match for the most part by the example you posted.

What I need to know is what you want to do with it because I will not give advice out for a problem I do not fully understand.

Here is an example of how to ask a question (if you want my help at any rate) in this thread.



I need to match all [size bbcodes? of the same size and replace them with a different size (or remove them, or change them to a custom bbcode etc etc)​

I need to match:
[size=2]lala[/size]
or [size=2Blah Blah[/size]

And then convert all instances of that match/matches to
[size=4]lala[/size]
or
[size=4]Blah Blah[/size][/INDENT]




Maybe i have a really big problem?

"/forum/showthread.php?p=295731#post295731"

Vbulletin could link to a post only with the postid; i dont know if xf can do this also?

The normal way seems to be threads/thread_id/#post_id=
If so i will need a php-script looking for all links with post_id only, find the thread_id and replace it like xf needs it.

Maybe this is a clean way, but more work. :)

Or is there a call for xf also with only the post_id?


A very small problem (as far as linking goes yes xf can link directly to a single post.)
- an example post link directly to your post above this: https://xenforo.com/community/posts/1104002

However for other reasons sometimes it is good to include the title in the link if available in the post already. I myself have written a script which can take the /posts links and convert them to the longer format with the thread title and all and use it when I am working on someone's site and they request that change.​
 
The problems are a lot of used tags in old posts from the old vbulletin.
People who used there size 2 for a readable size have now texts in a too small way.

I have not thought about, that it would be easier to change all [size=2 in [size=4, maybe i will do this now.

Before i tried to get rid of all [size=2 ... [/size
My tried regex only takes the first [size=2 and the last [/size; then i have to find [/size [size=2 many times between start and end.

I know that there is a way in perl to find one or more or all needles, but i dont know to say it in xenforo/php regex style.
I work with komodo, but the code i try there is not the same i need here.


The second problem is that we have a lot of urls without the t (for thread) and only with p (for posts), in vb it was enough to adress a post-id. Here in XF i dont know how to adress a thread/post only with the post id.

So the question is how i can come from showthreads.php?p=12345 to the right threadid here?

Maybe i have to write a small php-script looking for ?p=xxxx, get the thread and add a &t=yyyy?
From this i can do a regex again (or manage it directly in my script)

But maybe XF can manage this also?
 
The problems are a lot of used tags in old posts from the old vbulletin.
People who used there size 2 for a readable size have now texts in a too small way.

I have not thought about, that it would be easier to change all [size=2 in [size=4, maybe i will do this now.

Before i tried to get rid of all [size=2 ... [/size
My tried regex only takes the first [size=2 and the last [/size; then i have to find [/size [size=2 many times between start and end.

So if I understand correctly you already ran that expression you wrote and executed the changes on a site that you had imported from VB and you also did not back up your DB before you started running regex against the post and must fix this manually now?

If so that should be fixed before changing any other posts but without knowing exactly what you did I still can't advise you on what to do as I don't want to take responsibility for fixing an unknown erroneous regex replacement against a column in table while someone else uses my processes remotely on what I assume to be a live site... it's a scary thought.

Ultimately the best course of action is to not have the 'save changes' box checked until you know for sure it will work, I get that the broken result might not have showed itself for thousands of lines down the page so it is completely understandable.

Since I assume you are at this point already I would ask if you took a backup of your db before you started making replacements to it?

This is only an issue because unless every single closing /size was the last entry in each post that you replaced on you would have no way of knowing where to reinsert the [/size] closing tag nor can I say without seeing your regex if it would have caught strings starting with a size=2 wrapping but ending with a let's say size=5 wrapping and I am confident enough to say I don't think every post you changed ended in [/size] and I would guess that you don't want to just remove all size=ANYSIZE instances if that is the case.

I do hope for your sake that you backed up your DB before getting started or that your import to xf is not live yet.





(also you should put this around [plain] [size=2 , or [quote], [/ANYBBCODE] [/plain] , etc when you don't want it to parse in a post but want to show how it looks on your site this way someone like me can see what you actually intended to show me and so you can paste the actual text of the post you are making an example of)

I know that there is a way in perl to find one or more or all needles, but i dont know to say it in xenforo/php regex style.
I work with komodo, but the code i try there is not the same i need here.

This addon uses PCRE (Perl Compatible Regular Expressions) which literally uses the same syntax and semantics as Perl 5. I am not certain what you mean when you say komodo (there are many products with the name komodo/comodo) but the top hit for me on google was "Komodo Rx Toolkit" used for creating regex for you within the "Komodo IDE" point and click interface and that itself looks like it supports at least 6 flavors of regex each with small or great differences in semantics and syntax from the others.


The second problem is that we have a lot of urls without the t (for thread) and only with p (for posts), in vb it was enough to adress a post-id. Here in XF i dont know how to adress a thread/post only with the post id.


You can address a post id in xf like I posted above

Right click that link and open it in a new tab.


So the question is how i can come from showthreads.php?p=12345 to the right threadid here?

Maybe i have to write a small php-script looking for ?p=xxxx, get the thread and add a &t=yyyy?
From this i can do a regex again (or manage it directly in my script)



Well when you imported... if all your thread IDs and post ids stayed the same, then you can use regex alone usually to rewrite the links.

If a post on your VB site or a thread on your VB site does not match up with the post/thread of the same ID on your XF site then yes that would be import/post-import cleanup work most likely involving a script using regex for matching internal link references, extracting 'source id->destination id' , constructing the list of replacements for destination and applying the replacements which is outside of the scope of this addon.
But maybe XF can manage this also?

As far as the builtin XF importers managing this, it is highly unlikely though possible if they run out of things to do. There are a lot of other platforms one could be importing from thus there could be a lot of different format/syntax/url changes to account for and I would say at this point with the devs working on XF2 that it is probably not happening in the immediate if ever.

The scope of this is more the responsibility of the person doing the import though often times I find this stuff can take longer than the actual import itself.





Sleep time.
 
The original forum is still running, but without permission to post.
If anything goes wrong i can get data in parts.

A backup is running also from time to time and important tables have a copy to move them easily if needed, when i work with a table.

The problem is only size 2 and smaller, because this is too small in xf, but was standard in vb.

I am very happy to found the posts/12345 tonight also. At the first try it was not possible, maybe a typo, so i thought it is not build inside xf. Now i will replace them also.

Today i added two bb codes for thread and posts, so i will translate some of the internal links directly to the bb code, this is very helpful.

Thank you for the post. :)
 
I ask for help, please:

UPDATE table set field= CONCAT(UPPER(LEFT(field, 1)), RIGHT(field, LENGTH(field) - 1)) ";

=> LEFT(field, 1) = 1 Char from the left.
=> RIGHT(field, LENGTH(field) - 1) = from the right take all (the length) -1;


This one should upper my first char only. But it makes funny things like:

I want to have: Name
but i get sometimes(!)
NName or Nname

Ok, i have seen now names like NNName; seems that there is a new N every time i query mysql again.



------------------

I would like to have a replacement for this:

Name >> something i dont want

From here i want to have only Name; not the rest. The important chars are thse here: ">>", they are always inside the field.



I am asking for mysql, because i have to replace things in different tables, not in post.

Thank you very much.


-----
Ok. I have testet some different data and it seems that the LENGTH-function sometimes dont work correct.

Now, i have some wonderful datasets with NNNNName and no idea how to replace it with mysql, but maybe with php.
 
Last edited:
After using the addon from Andy to insert all attachments as full i have another big problem;
in many posts i have now something like:

(ATTACH=full]59948.vB(/ATTACH]

in the text

(ATTACH=full]59944(/ATTACH]

and this at the end.


Is there a clever regex to find


(ATTACH=full]59948.vB(/ATTACH] *. (ATTACH=full]59944(/ATTACH]

one time and replace the last attach with nothing, then start again and again and again till the posts are ok again?
 
Use the "code" BBcode tags (instead of replacing the "[" with something else) and provide specific examples of exactly what you are seeing and exactly what you need it to look like



How did Andy's addon screw things up?
 
I have no idea;
maybe it is from using both scripts: insert all and insert while save; and maybe the problem is that .vB; if Andy has no regex for checking .vB the script will find nothing and insert.


An Exact Example is:

Code:
Huhu , lelele , blublubu, Text from post

[ATTACH=full]59948.vB[/ATTACH]

Haha, lalala, blabla, Text from post

[ATTACH=full]59944[/ATTACH]



Should/can i do this with the find/replace?
Or should i write a php that is looking for the right posts,
searching for attach xxx.vB /attach;
then checking if attach xxx /attach is inside and replace it with ""
 
Somehow i think it will need more steps than one:

is there attach xxx.vB /attach
-- is there attach xxx /attach
yes?
- Then replace attach xxx /attach with ''
- Then replace .vB with ''
 
the regex will only target the specific strings that are #####.vb and replace that with #####, and it will leave the others that are already ##### alone....
 
I have done it with

seach for attach xxx .vB /attach
while
replace attach xxx attach/
replace xxx .vB

With this code i had to replace one and the same post till ten times, but everything is fine now (i hope).
 
New old problem:

Code:
[surl=/po/6/0/600.php]some text[/surl] some Text 2[surl=/po/2/0/700.php]more text[/surl]

My regex is now:

Code:
\[surl=/po/(\d/)+(\d+).php](.*)\[/surl]

replace it with
Code:
[link=\2]\3[/link]

The regex is fine as long i have only one time surl and /surl.

The problem is the .* that eats everything till the last /surl.

And i have no idea to tell something like:

.* everything, but not [

then i will get only the first surl and /surl and that would be ok for me.
 
Would someone be kind enough to help me replace all the links on my forum to the new url? I'm changing from "cogumelosmagicos.org" to "teonanacatl.org"

What would be a correct regex? Of course these links would have /forums/ and all shorts of other xenforo hierarchy after the domain.

Thanks!
 
Back
Top Bottom