After my webform is submitted, regex will be applied to user input on the server side (via PHP). I'd like to have the identical regex running in real-time on the client side to show the user what the real input will be. This will be pretty much the same as the Preview section on the Ask Question pages on StackOverflow except with PHP on the back-end instead of .NET.
What do I need to keep in mind in order to have my PHP and JavaScript regular expressions act exactly the same as each other?