jdmdevdotnet
jdmdevdotnet

Reputation: 1

Remove set of string from a string, multiple occurences

Want to completely remove any part of my string that has

\"AddedDate\":\"\\/Date(1480542000000-0600)\\/\"

The 1480526460000-0600 is not hardcoded, it could be any set of numbers (JSON dates).

Upvotes: 0

Views: 29

Answers (1)

Nicolas
Nicolas

Reputation: 7081

Try this regex \"AddedDate\":\"\\\/Date\(\d+(?:-\d+)?\)\\\?\" and replace with empty string. If the regex engine doesn't support \d, replace them with [0-9]. This will match date format like x or x-x, x being any number of digits.

If you want to match exactly 13 numbers in the first part of the date and 4 in the second, use \"AddedDate\":\"\\\/Date\(\d{13}(?:-\d{4})?\)\\\?\"

EDIT: For new format use \\\"AddedDate\\\":\\\"\\\\\/Date\(\d+(?:-\d+)?\)\\\\\/\\\" it should work.

Upvotes: 1

Related Questions