I am a newbie to Regex and require help with the following:
I have strings like - B - Comp-Band Disk,C - Check Oncoming Private,D - DL Procurement Outer
. Is there a Regex expression which I could use to change string to B,C,D
?
CodePudding user response:
You can use
(?:(?:^|,)(\w))
Regex Explanation
(?:
Non-capturing group(?:
Non-capturing group^|,
Match start of the string or,
)
Close non-capturing group(
Capturing group\w
Match any word character
)
Close group
)
Close non-capturing group
See the demo