We’re talking about RegEx: http://www.regular-expressions.info/
Wait, isn’t that just about rebaking, and he also needs to run a
rake posts:remap first? If so, does remapping also support regular expressions?
Oops You are right. I shouldn’t post that late at night
posts:remap rake task doesn’t support regular expressions, but it is using the SQL
find parameter is reused within a regex. But with a few changes this could certainly work.
Just submitted a PR:
> rake posts:remap['pattern', 'replace', type] > rake posts:delete_word['pattern', type]
After having implemented the change, I came to realize that supporting regex pattern for
delete_word might be a bit dangerous? There are confirmation prompts in place, but these actions are still nonetheless irreversible and enabling regex matching might include a much larger set of posts than intended.
Maybe we could have something like
rake post:remap_plan['pattern', 'replace', type] which would not change anything, but only display, something like the 100 first impacted posts (and what is going to change) ? So you could have a better idea of what is going to happen. Thoughts?
The convention is to accept a
--dry-run option for that, so it’s easy to delete when you’re ready.
The question is not on the syntax and it’s a rake task so having options is doable but a little bit unexpected so
rake post:remap['pattern', 'replace', type] DRY_RUN=1 would probably be more in the spirit of rake
So, if one was to use this to change a username…
<a href="/u/jcoates" class="mention ">@jcoates</a>
Can you just find/replace the whole html mention link? Is there anywhere in the database that mentions are stored other than in the posts themselves?
Yeah I was thinking along those lines.
Displaying the information in a clear and concise manner is critical though, especially when it comes to a large number of posts and/or lengthy matches. I’ll look into some possibilities.
AFICT, that’ll work and there are nothing else you’ll need to change.
hmmm… just thinking… what about the user’s previous posts. Is there a need to find/replace the author info or is this just built off of the author’s user ID?
Incidentally, i ran into an odd problem where people got notified when i ran this command to rename a group that was mentioned in a bunch of posts going back a few years. It was not consistent but somehow some group members got email notifications. I did not take the time to troubledhoot and just apologized to those affected. But next time i will try to remember to suppress email notifications before doing this again.
There is a bug around editing we have had for some time where it will trigger re-notification inappropriately in some cases.
6 posts were split to a new topic: How to replace a string/character in topic title?
how can i add a new line/line break before or after a specific string which i want to replace? same for whitespace/space bar.
i want to remove
[img]-tags, some of them nested inside a
[url]-tag, which prevents the remote image download.
<br/> before/after the replacement string should work:
adding a new line worked. thanks @xrav3nz.
[img] seem to be another problem with some specific urls, but thanks!
Any chance to get replacement patterns as key/value pairs in admin settings, with preview and automatic “watch” mode for each new post or post edit?
Use-case: I’d like to replace
:) automatically. Some people put lots of parenthesis instead of emojis and it looks terrible, the text looks spoiled by parenthesis. I’d like not to bother people by asking them not to do so, but rather replace automatically with a regex. There are more examples in punctuation normalization:
'!!!` => ‘!’
This could be used to strip out signatures that come by way of posts made by email.
Yep, we have this issue too
It is possible to remove all Mybb text style tags from the posts.
I am talking about  tags like or [color="#fffff"] [/color]. I want to search all  and [/] tags, whatever the value is, and remove them. And i need any suggestion about that.
I wan to delete “[font=‘Open Sans’, sans-serif]” string with rake posts, but it doesnt work.
rake posts:delete_word["[font=‘Open Sans’\,\ sans-serif]"]
Processing 0 posts updated!