I would like help with solving a problem using regular expressions.
I've written the following JavaScript code:
var s = '/Date(1341118800000)/';
var regex = new RegExp('^/Date\(\d+\)/$');
if ( typeof s === 'string' && s.match(regex) )
s = 'abc';
alert (s);
I have written a regex that I want to match strings that begin with the following exact characters: /Date( followed by one or more digits, followed by the exact characters )/ and nothing more.
In the above JavaScript code, I expect that the string 'abc' should be assigned to s, but at the conclusion of this code, the value of s is '/Date(1341118800000)/'.
How can I fix this?
smatches the regular expression, the string 'abc' should be assigned tos.s = '/Date(1341118800000)/' == s ? "abc" : s;