i have file need use regex replace specific character. have strings of following format:
1234 4215 "aaa.bbb" 5215 1524 and need replace periods colons. know these periods contained within quotation marks, need regex finds substring starts '"', ends '"', , contains "." , replace "." ":". shed light?
you can use:
str = str.replaceall("\\.(?!(([^"]*"){2})*[^"]*$)", ":"); this regex find dots if inside double quotes using lookahead make sure there not number of quotes after dot.
Comments
Post a Comment