01-12-2021, 01:51 AM
Hello everyone,
I need to make a judgment, but can't get the right result, I hope someone can point out the mistake. Thanks in advance
If s is a number or variable name, out s, else out "s"
Expected output:
Case 1 a2
Case 2 _b
Case 3 3
Case 4 "2a"
Case 5 "C:\Users\Administrator\Desktop\test.txt"
Case 6 "C:\Users\Administrator\Desktop"
Case 7 "世界"
Macro q1
I need to make a judgment, but can't get the right result, I hope someone can point out the mistake. Thanks in advance
If s is a number or variable name, out s, else out "s"
Expected output:
Case 1 a2
Case 2 _b
Case 3 3
Case 4 "2a"
Case 5 "C:\Users\Administrator\Desktop\test.txt"
Case 6 "C:\Users\Administrator\Desktop"
Case 7 "世界"
Macro q1
;str s="a2" ;;Case 1
;str s="_b" ;;Case 2
;str s="3" ;;Case 3
str s="2a" ;;Case 4
;str s="C:\Users\Administrator\Desktop\test.txt" ;;Case 5
;str s="C:\Users\Administrator\Desktop" ;;Case 6
;str s="世界" ;;Case 7
if(findrx(s "^[a-zA-Z_][a-zA-Z0-9_]*") or findrx(s "\d+"))
,out s
else
,out F"''{s}''"
;Expected output:
;Case 1 a2
;Case 2 _b
;Case 3 3
;
;Case 4 "2a"
;Case 5 "C:\Users\Administrator\Desktop\test.txt"
;Case 6 "C:\Users\Administrator\Desktop"
;Case 7 "世界"