Given a string like that:
"CSV;XML;ZIP"
I'm trying to make a regex to transform it to something like that:
".csv,.xml,.zip"
I tried this regex pattern : ([^;]*)(;|$)
replace with: .\L$1,
but the result is : .csv,.xml,.zip,.,
I need my regex to satisfy :
- "CSV" -> ".csv"
- "CSV;XML;ZIP" -> ".csv,.xml,.zip"
I feel like I need to add something inside my regex which says: if it is the end of the string don't add ',' else do, but I don't know how to do it.
replace
regex methods. If you are not "married" to regex, 1) lowercase the input, 2) split with;
and 3) join with,.
and append.
at the start.+
, not*
.([^;]+)(;|$)