I have the following JavaScript:
var value = '19-JUL-10 04.36.38.643000 PM-->19-JUL-10 05.06.33.962000 PM'
How can I use jQuery to trim it to become '19-JUL-10 04.36.38 PM-->19-JUL-10 05.06.33 PM'
?
No need for jQuery, plain ol' JavaScript will do. Use a regular expression with the replace() method:
var value = '19-JUL-10 04.36.38.643000 PM-->19-JUL-10 05.06.33.962000 PM';
alert(value.replace(/\.\d{6}/g, ""));
//-> "19-JUL-10 04.36.38 PM-->19-JUL-10 05.06.33 PM"
The regular expression, /\.\d{6}/g
, looks for a .
immediately followed by and including 6 consecutive digits (\d{6}
). The global switch (/g
) is applied to make it replace all (both) occurrences.