Question Gayle Congdon · 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

Comments

Dmitry Maslennikov · Aug 7, 2023

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
0
Gayle Congdon  Aug 7, 2023 to Dmitry Maslennikov

Thanks so much Dmitry - thats perfect.  Really appreciate the help.

Have a great day :)

0
Herman Slagman · Aug 8, 2023

You can use Objectscript pattern matching:
Set String="a=b"
Write String?.e1P.e => 1
The case isn't important, just to highlight the 1P(unctuation)

0