Using prxchange, how can I replace the : in the below string with a space. This is only an example of the string, so to make it as dynamic as possible please. i.e. the string may not be in this exact order, or it may be longer/shorter. I only want to remove the colon between 3Sbvx6822:Mcnt8969, and leave the rest.
have: {"var1":"0","var2":"3Sbvx6822:Mcnt8969","var3":"0","var4":"0","var5":"0"}
want: {"var1":"0","var2":"3Sbvx6822 Mcnt8969","var3":"0","var4":"0","var5":"0"}
using the below code partially worked, but removed 3Sbvx6822: rather than just the :
prxchange('s/(\w+:)//oi', -1,trim(keyvaluepairs))
Any help is appreciated.
Cheers.
Hello @94seanhogan and welcome to the SAS Support Communities (as a first-time poster)!
You could replace a string of word characters followed by a colon with that same string followed by a space:
want=prxchange('s/(\w+):/$1 /',-1,keyvaluepairs);
Or replace a colon, if preceded by a word character, with a space:
want=prxchange('s/(?<=\w):/ /',-1,keyvaluepairs);
Hello @94seanhogan and welcome to the SAS Support Communities (as a first-time poster)!
You could replace a string of word characters followed by a colon with that same string followed by a space:
want=prxchange('s/(\w+):/$1 /',-1,keyvaluepairs);
Or replace a colon, if preceded by a word character, with a space:
want=prxchange('s/(?<=\w):/ /',-1,keyvaluepairs);
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.