Question
· Aug 7, 2023

How to check an input string for special characters

Hi,

I am new to Objectscript so need some help please.

How would I check a string for special characters as per below?

/^[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]*$/

Thanks so much,

Product version: IRIS 2022.1
Discussion (3)2
Log in or sign up to continue

you can use $zstrip, where action *P, * is for any place, and P any punctuation

for example

USER>write $zstrip("before!@#$%^&*()_+\-=\[\]{};':""\\|,.<>\/?after", "*P")
beforeafter

And if you just want to check if the string contains any punctuations, you can compare if the original string does not equal the same after $zstrip.

if you wish to use regexp, you can use $match

USER>write $match(".!@", "^[!@#$%^&*()_+\-=\[\]{};':""\\|,.<>\/?]*$")
1