Color pattern:Problem: The pattern /\[color=(['\"]?)([a-zA-Z0-9#]*)\\1](.*)\[\/color\]/sU is expecting the color value to be enclosed in either single quotes or double quotes, but the example [color=009900] doesn't have any quotes.
Solution: We remove the quote capturing group and make it optional: /\[color=(['\"]?)([a-zA-Z0-9#]+)\\1?](.*)\[\/color\]/sU
Size pattern:Problem: The pattern /\[size=(['\"]?)([a-zA-Z0-9.#]*)\\1](.*)\[\/size\]/sU is allowing dot (.) and hash (#) characters in the size value, which are not valid for font sizes.
Solution: We remove the dot (.) and hash (#) characters from the size value capturing group: /\[size=(['\"]?)([a-zA-Z0-9-]+)\\1?](.*)\[\/size\]/sU
The updated patterns make the quotes optional by using \\1? instead of \\1.
This allows the color and size values to be specified with or without quotes.
Color pattern: Problem: The pattern
/\[color=(['\"]?)([a-zA-Z0-9#]*)\\1](.*)\[\/color\]/sU
is expecting the color value to be enclosed in either single quotes or double quotes, but the example[color=009900]
doesn't have any quotes. Solution: We remove the quote capturing group and make it optional:/\[color=(['\"]?)([a-zA-Z0-9#]+)\\1?](.*)\[\/color\]/sU
Size pattern: Problem: The pattern
/\[size=(['\"]?)([a-zA-Z0-9.#]*)\\1](.*)\[\/size\]/sU
is allowing dot (.
) and hash (#
) characters in the size value, which are not valid for font sizes. Solution: We remove the dot (.
) and hash (#
) characters from the size value capturing group:/\[size=(['\"]?)([a-zA-Z0-9-]+)\\1?](.*)\[\/size\]/sU
The updated patterns make the quotes optional by using
\\1?
instead of\\1
. This allows the color and size values to be specified with or without quotes.