It sounds like your JavaScript code was using a regex that expected the quote tag to include literal parentheses around the identifier (for example, [quote=(Alice)]), but your input might not have those parentheses (for example, [quote=Alice]). This mismatch is why your converter wasn’t working as expected.
For example, the regex
/\[quote=\((.*?)\)\](.*?)\[\/quote\]/is
expects that after [quote= there is a literal (, then some content (captured in group 1), then a ), followed by ], then the quote content.
If your input is actually like:
[quote=Alice]Hello, World![/quote]
you’ll need to modify the regex so that it doesn’t look for literal parentheses. One way to do that is to remove the escaped \( and \) from the pattern. For example, you could use:
/\[quote=(.*?)\](.*?)\[\/quote\]/is
This pattern works as follows:
- It matches
[quote= literally.
- Then
(.*?) greedily (but non-greedily, actually) captures anything (the identifier) until the closing ]
- Then it matches
\] literally.
- Next,
(.*?) captures the quoted message.
- Finally, it matches the closing tag
[/quote].
If you want the regex to optionally match parentheses (in case some quotes have them and others don’t), you can do something like making them optional. For example:
/\[quote=(?:\((.*?)\)|(.*?))\](.*?)\[\/quote\]/is
This version uses a non-capturing group (?: ... ) with two alternatives:
\((.*?)\) looks for an identifier wrapped in literal parentheses.
(.*?) as an alternative for an identifier without parentheses.
Then, (.*?) after the identifier captures the quote content.
With this approach, if you have:
[quote=(Alice)]Hello![/quote] → then group 1 (from the first alternative) will capture "Alice"
[quote=Alice]Hello![/quote] → then group 2 (the second alternative) will capture "Alice"
You might then need to combine results from group 1 and group 2 in your JavaScript code (for example, use whichever one is non-empty).
I hope this clears things up and helps you adjust your regex to match your actual input. If you have any more questions or need further modifications, feel free to ask!