If you have a fair number of regular expressions used by both client (javascript) and server side code (C#, vb.net) and want to store them in one place to avoid duplication, where do you store them?
I could use registerscript and write out the regex as strings, but just wondering if there is something more elegant.
I took a look into the above two solutions but wound up doing something more prosaic. The JSON solution intrigues me, but I’m not familiar with JSON.NET and will have to try it out one day and I didn’t want to store the expressions in an asp.net page, but the regex comparison chart came in handy.
I went with a simple xml file which I was using for other things, so it was there already.
For the server-side, I used the built in .NET functions to retrieve the regexes from the xml file and on the client-side, used jQuery’s ajax request to get the regexes in Javascript.