I have a date type string yyyy-MM-ddTHH:mm:ss
(2018-04-18T00:00:00)
I want to match :
and replace it with %3a
match -
replace it with %2d
this my Regexp DEMO: https://regex101.com/r/rqpmXr/11
my output 2018%3a04%3a18T00%3a00%3a00
my expected output need to be like that 2018%2d04%2d18T00%3a00%3a00
String date = "2018-04-18T00:00:00";
date = date.replace("-","%2d").replace(":","%3a");
I think it's much easier to use String.replace() method for your case.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.