Https://stackoverflow.com/questions/63929065/click-event-isnt-working-on-ios-and-safari

Does anyone know how to modify this code so it can work on all platforms?
it works on windows and chrome but not on iPhone/Desktop or any Safari browser
I attached a link to Stack Overflow below. Thanks!

Thank you for your insight, it works! I will avoid regular expressions for these environments.