Created
January 10, 2021 10:31
-
-
Save timotewb/c7d88314c2c1ffa46c8ef8ba40c69001 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* setup test data*/ | |
data test_data; | |
input raw_string & $50.; | |
datalines; | |
001-5845-69995 | |
t3sting_%$£ h^%)k | |
this one should be 100 percent fine | |
B*FHE`£lDO | |
; | |
run; | |
title "work.test_data"; | |
proc print data=test_data; run; | |
/* run prxmatch and prxchange on test data */ | |
data result_data; | |
set test_data; | |
if prxmatch('/[^A-Z 0-9]/i',raw_string) then do; | |
special_char_found = 1; | |
special_chars_list = prxchange('s/[A-Z 0-9]//i',-1,raw_string); | |
clean_string = prxchange('s/[^A-Z 0-9]//i',-1,raw_string); | |
end; | |
else do; | |
special_char_found = 0; | |
end; | |
run; | |
title "work.result_data"; | |
proc print data=result_data; run; | |
/* add underscore to regular expression */ | |
data result_underscore_data; | |
set test_data; | |
if prxmatch('/[^A-Z 0-9_]/i',raw_string) then do; | |
special_char_found = 1; | |
special_chars_list = prxchange('s/[A-Z 0-9_]//i',-1,raw_string); | |
clean_string = prxchange('s/[^A-Z 0-9_]//i',-1,raw_string); | |
end; | |
else do; | |
special_char_found = 0; | |
end; | |
run; | |
title "work.result_underscore_data"; | |
proc print data=result_underscore_data; run; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment