I am new to regex and unable to create a expression to resolve my problem.
I have a string like /abc/def%20hi%28hello%29test
. I would like to replace the hexadecimal characters, that is, %20
, %28
and %29
with -
I know all three of them have different meanings, but I am fine with replacing all with any single character, I mean -
or even .
or ' '(space).
So, I would like to get the output as /abc/def-hi-hello-test
.
I thought to find %
and replace three characters from %[a-zA-Z0-9][a-zA-Z0-9]
with -
, but doesn't work.
Can some please help me write a regex which just replaces those hexadecimal characters?