Resource icon

Post Content Find / Replace 2.0.1

No permission to download
What when you use simply a " " (whitespace) instead \n or \t ? I think \s like at the regex code will not work at replacement string - but I havent tested yet.
XenForo though will auto clear whitespace on Replacement Filed :/.
 
Ok, I think thats a ask for @Brogan or @Chris D or @Mike or similar guys how can know about that stuff.

I think a simple html whitespace wont work, or?
HTML:
 





But - I have a solution, you can play with: litle bit ugly, but can work. :D ;)
Regex
Code:
#(\s)([\[CQ\=']+)([\w\-\s]+)([c:\s0-9,m'\]\[\/CQ\]]+)(\s)#si
I add 2 groups - one at beginning and one at the end to match whitespaces at both places.

Replacement
Code:
$1@$3$5
Therefore we have to change the replacement string to fit the new groups... username group # changed to $3 in this case!

If your old bbcode have every time a whitespace bevore and after the bbcode it should work.
 
  • Like
Reactions: rdn
Can anyone help change this
Code:
https://youtu.be/123456789
to this?
Code:
[MEDIA=youtube]123456789[/MEDIA]
Yes, it is correct there are no current bbcodes. It's text. Thanks!
 
Hi there.

I want to replace
Code:
https://www.youtube.com/watch?v=12345678
with
Code:
[media=youtube]\1[/media]

What do I have to search for, I mean, what do I have to type in?

Almost forgot: There are also a few
Code:
https://youtu.be/12345678

that need to be changed.
What did you use for the short one?
 
There are so many examples now at the last two ore three sites of this thread, certain of it contains 95% of the solution you search for... oh man.

based on your data example:
Code:
https://youtu.be/123456789

fast find:
Code:
 https://youtu.be/

regex:
Code:
#( )(https:\/\/youtu\.be\/)([a-zA-Z0-9-_?%&]+)( )#siu

replace:
Code:
$1[MEDIA=youtube]$3[/MEDIA]$4

But check if that finds and replace only the right one type of links!

1631385210274.png

Try to learn regex - iam also only a farmer and do some it stuff only at my free time. Regex is not so complicated as you think at the beginning.
 
This one worked except for URLs with a hyphen:
If I can just get that one to include a hyphen! And disregard URL tags as stated. 😁
 
I give up - you doesnt understand the basics like it is working.
A "doesnt work" without a helpfull error desciption is a little bit senseless.
You are not able to explain WHAT is not working or give some screens so other ones can see whats wrong.

For the given Examle - my regex above works. But when your example doesnt fit what you realy will do, its impossible to help you.

This way its realy time wasting for me. Sorry.
Good luck! :)
 
No problem. Thanks for trying.

The one you posted has 0 results so it must have an error. No screenshot is needed to show no results. The one I found in the link posted pulls up hundreds of results except it needs to accept codes with a hyphen.

If anyone can help out thanks!
 
Last edited:
You are not able to explain WHAT is not working or give some screens so other ones can see whats wrong.
I don't see how a screenshot is helpful but this returns 0 results as seen here:
no results.png

And no that doesn't mean there are no instances of youtu.be links because here they are here:

no results 2.png
 
Last edited:
You have to look why the fast search nothing can find - I doesnt can take a look at your admin area, so this part (fast search) is your part.

Take a look at white spaces - with or without can be important.

And at last - screenshots from examples with text around the example can also be helpfull... that is what I mean but yes, also screens from not working code can help to check if there is a type error or copy and paste error. :rolleyes:
 
Just write me a PN with these infos:

1. several examples of the BBcode you wish to change
2. several examples of posts, where the old BBcode is used within text

Than I can take a look how we can fix it. :)
 
Hi, I have multiple instances of wrong BB code in my newly Imported forums.

This is a sample of what needs to be found
Code:
[URL='http://filedata/fetch?id=2151&d=1612502132'][ATTACH type="full" width="30%" alt="Click for bigger size.  Name: DJ824_0.jpg  Views: 0  Size: 195.1 Kb"]1319[/ATTACH][/URL]

More examples of counting
[URL='http://filedata/fetch?id=2155&d=1612502244'] 
[URL='http://filedata/fetch?id=2149&d=1612502164']
[URL='http://filedata/fetch?id=2150&d=1612502223']
[URL='http://filedata/fetch?id=2148&d=1612502159']
[URL='http://filedata/fetch?id=2153&d=1612502153']
[URL='http://filedata/fetch?id=2154&d=1612502289']
[URL='http://filedata/fetch?id=2152&d=1612502141']

Find and remove URL with all the variability.
Code:
[URL='http://filedata/fetch?id=2152&d=1612502141'] [/URL]

So I need to loose the URL bit and end with a clean BB
Code:
[ATTACH type="full" width="30%" alt="Click for bigger size.  Name: DJ824_0.jpg  Views: 0  Size: 195.1 Kb"]1319[/ATTACH]

All help greatly appreciated


I need to loose the URL bit and end with a clean BB
Code:
[ATTACH type="full" width="30%" alt="Click for bigger size.  Name: DJ824_0.jpg  Views: 0  Size: 195.1 Kb"]1319[/ATTACH]

All help greatly appreciated
 
Hi, I have multiple instances of wrong BB code in my newly Imported forums.

This is a sample of what needs to be found
Code:
[URL='http://filedata/fetch?id=2151&d=1612502132'][ATTACH type="full" width="30%" alt="Click for bigger size.  Name: DJ824_0.jpg  Views: 0  Size: 195.1 Kb"]1319[/ATTACH][/URL]

More examples of counting
[URL='http://filedata/fetch?id=2155&d=1612502244'] 
[URL='http://filedata/fetch?id=2149&d=1612502164']
[URL='http://filedata/fetch?id=2150&d=1612502223']
[URL='http://filedata/fetch?id=2148&d=1612502159']
[URL='http://filedata/fetch?id=2153&d=1612502153']
[URL='http://filedata/fetch?id=2154&d=1612502289']
[URL='http://filedata/fetch?id=2152&d=1612502141']

Find and remove URL with all the variability.
Code:
[URL='http://filedata/fetch?id=2152&d=1612502141'] [/URL]

So I need to loose the URL bit and end with a clean BB
Code:
[ATTACH type="full" width="30%" alt="Click for bigger size.  Name: DJ824_0.jpg  Views: 0  Size: 195.1 Kb"]1319[/ATTACH]

All help greatly appreciated
 
???

we need a old string and in best case a new one (like it should be after search and replace) with the same picture/Attachment ID

I can't see anything in common between your old string and the new one? I think at least the ID should be the same. ;)

In your old examples the ID will be "2151" eg and at your new one you have "1319" - work the new one also with "2151" unstead of "1319" or not?
 
we need a old string and in best case a new one
Sorry I thought I was explaining things well 😅

OLD STRING
Code:
[URL='http://filedata/fetch?id=2151&d=1612502132'][ATTACH type="full" width="30%" alt="Click for bigger size.  Name: DJ824_0.jpg  Views: 0  Size: 195.1 Kb"]1319[/ATTACH][/URL]

NEW STRING
Code:
[ATTACH type="full" width="30%" alt="Click for bigger size.  Name: DJ824_0.jpg  Views: 0  Size: 195.1 Kb"]1319[/ATTACH]

Due to the number of strings and variations, I added more string beginnings in previous post.
 
Sorry I thought I was explaining things well 😅

OLD STRING
Code:
[URL='http://filedata/fetch?id=2151&d=1612502132'][ATTACH type="full" width="30%" alt="Click for bigger size.  Name: DJ824_0.jpg  Views: 0  Size: 195.1 Kb"]1319[/ATTACH][/URL]

NEW STRING
Code:
[ATTACH type="full" width="30%" alt="Click for bigger size.  Name: DJ824_0.jpg  Views: 0  Size: 195.1 Kb"]1319[/ATTACH]

Due to the number of strings and variations, I added more string beginnings in previous post.

untested:

Code:
Search: /\[URL=[^]]*?\](.*?)\[\/URL\]/

Replace: \1

I'd test it using this: https://xenforo.com/community/resources/bs-regex-censor.7452/ before making any database changes.
 
Back
Top Bottom