Reputation: 155
I'm trying to match the special characters and the breaks using a regex to cleanse the string so that I'm left with only the following string 'All release related activities' extracted from the following line:
{"Well":"\n\n\t\n\t\n\n\t\n\tAll release related activities\n\n\t"}
I've tried the regex ^{.Well":"
and I'm able to match till the first colon appears. How do I match the \n characters in the string?
Upvotes: 1
Views: 1361
Reputation: 44043
Try:
/":"(?:\\[nt])*(.*)}"$/
":"
Matches ":".(?:\\[nt])*
Matches 0 or more occurrences of either \n
or \t
.(.*)
Matches 0 or more characters in Capture Group 1 until:}"$
Matches }"
followed by the end of the string.The string you are looking for is in Capture Group 1.
Upvotes: 1
Reputation: 10466
I am not quite sure about the prefix of "well:" So I am basically providing you with a basic regex:
^\{[^}]*?(?:\\[ntr])+([^}]+)\}
and replace by:
\1
Upvotes: 1