indie Posted February 6, 2021 Share Posted February 6, 2021 (edited) I am trying to change this [sharedmedia=core:attachments:****] into this [ATTACH]****[/ATTACH] And leave the same numbers intact, the *s are unique numbers per post. Thanks for any help! Edited February 6, 2021 by indie Quote Link to comment https://forums.phpfreaks.com/topic/312103-a-little-query-help-needed-thanks/ Share on other sites More sharing options...
requinix Posted February 6, 2021 Share Posted February 6, 2021 Could create a second BBCode tag that turns [attach] into [sharedmedia], so both tags would be supported. Actually I rather suggest that in case there's something still using or generating [sharedmedia]s - wouldn't want to break those. Would also mean not having to deal with the database. If you have a more specific question, like what code you have to write or regular expression to create, then you should probably ask that. Quote Link to comment https://forums.phpfreaks.com/topic/312103-a-little-query-help-needed-thanks/#findComment-1584281 Share on other sites More sharing options...
indie Posted February 7, 2021 Author Share Posted February 7, 2021 Not two codes no. Yes, looking for regex to take care of it. Quote Link to comment https://forums.phpfreaks.com/topic/312103-a-little-query-help-needed-thanks/#findComment-1584299 Share on other sites More sharing options...
requinix Posted February 7, 2021 Share Posted February 7, 2021 What have you been able to come up with so far, and what happened/didn't happen when you tried it? Quote Link to comment https://forums.phpfreaks.com/topic/312103-a-little-query-help-needed-thanks/#findComment-1584301 Share on other sites More sharing options...
indie Posted February 8, 2021 Author Share Posted February 8, 2021 Unfortunately nothing, that's why I am asking. This is not my skill department. But I can surely paste a query lol. What I need is a regex code to change the above. So where the **** would be 6453, in the below code, the **** would also be 6453. So all it keeps is the attachment number. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/312103-a-little-query-help-needed-thanks/#findComment-1584325 Share on other sites More sharing options...
requinix Posted February 8, 2021 Share Posted February 8, 2021 Creating the regex is fairly straightforward: start with the literal string you want to find, escape any special characters that you don't want to be special (like the [ ]s), then substitute in stuff like (\d+) where you want to find numbers. The replacement string works much the same way, and you can reference the matched numbers from before using $1 or \1 (careful of the backslash). Honestly, you're probably overestimating how difficult this will be. Quote Link to comment https://forums.phpfreaks.com/topic/312103-a-little-query-help-needed-thanks/#findComment-1584327 Share on other sites More sharing options...
indie Posted February 9, 2021 Author Share Posted February 9, 2021 That's all Greek to me. Looking for someone to post it for me, can pay. Quote Link to comment https://forums.phpfreaks.com/topic/312103-a-little-query-help-needed-thanks/#findComment-1584329 Share on other sites More sharing options...
awjudd Posted March 2, 2021 Share Posted March 2, 2021 @indie I know I'm coming fairly late, but here is your Regex: \[sharedmedia=core:attachments:(\d+)\] https://rubular.com/r/fOGRTK3l3LcLx1 1 Quote Link to comment https://forums.phpfreaks.com/topic/312103-a-little-query-help-needed-thanks/#findComment-1584831 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.