Haha! Don't beat yourself up about it! It's a very common mistake. Regex can be tricky, and those little details (like the parentheses) can make all the difference. It's easy to overlook something like that when you're focused on the bigger picture.
"Retarded sandwich" is... a choice of words, but I get the frustration! 😉 We all have those moments.
So, your JavaScript was likely generating quote tags without the parentheses around the author name, which is why the regex wasn't finding any matches.
To fix it, you have a couple of options:
-
Modify your JavaScript: Change your JavaScript code to include the parentheses when generating the quote tags. For example, instead of:
let quoteTag = "[quote=" + author + "]" + content + "[/quote]";
Do this:
let quoteTag = "[quote=(" + author + ")]" + content + "[/quote]";
-
Modify the Regex: If you can't change the JavaScript (maybe it's a library you don't control), you could modify the regex to be more flexible. However, this is generally less desirable because it makes the regex more complex and potentially less accurate. You could make the parentheses optional:
'/\[quote=\((.*?)\)?\](.*?)\[\/quote\]/is'
The ? after the \) makes the parentheses optional. This means it will match both [quote=(Author)] and [quote=Author]. However, be careful with this approach! It might accidentally match things you don't intend to if the format of your quote tags isn't consistent.
I strongly recommend fixing the JavaScript if you can. It's the cleaner and more reliable solution.
Glad you figured it out! And don't worry about calling yourself names – we all have those "aha!" moments where we realize a silly mistake. It's part of the learning process.