Is there a way to run regex expressions on a variable?

Got a problem you cannot solve? Try here.
norbertjurkiewicz
Posts: 16
Joined: Thu Aug 02, 2012 11:07 am

Is there a way to run regex expressions on a variable?

Postby norbertjurkiewicz » Mon Aug 06, 2012 2:04 pm

I'd like to validate and reformat user input to make valid strings. The parse utility isn't up to the par.

FrancescoT
Site Admin
Posts: 5361
Joined: Sun Aug 22, 2010 4:28 am

Re: Is there a way to run regex expressions on a variable?

Postby FrancescoT » Tue Aug 07, 2012 10:17 am

Dear User,

Actually string parse operations are only available the Parse String command.

Otherwise you should write some custom component as a DLL.

Regards
Francesco Toscano
InstallAware Software

White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Publications - http://www.installaware.com/publications-review.htm
InstallAware Help -F1 anywhere in the InstallAware IDE

chaoix
Posts: 5
Joined: Fri Mar 04, 2016 1:57 pm

Re: Is there a way to run regex expressions on a variable?

Postby chaoix » Fri Mar 11, 2016 12:00 pm

I was able to find a workaround for basic pattern matching (regex-like) using the "findstr" command-line tool.

Here is some example code that validates a variable to be all digits:
~InstallAware Clipboard Data~
~End~
~{4ACE424D-8E60-4CAF-8EA5-3C827A6AFAA7}~
~Comment~
~{3940C235-FD86-47FB-9CB1-A9A322B42769}~
~$SKLICENSE$ is not all digits~
~If~
~{48F5CE56-A1B0-4888-A808-AC9C76F0F160}~
~SKLICENSEIDFORMATTED~
~0~
~1~
~FALSE~
~Run Program As~
~{DF50660E-3808-4B73-8BA4-1B376DEACBF4}~
~cmd.exe~
~~
~/c "echo("$SKLICENSEID$"|findstr "^[\"][-][1-9][0-9]*[\"]$ ^[\"][1-9][0-9]*[\"]$ ^[\"]0[\"]$">nul&&exit 0||exit 1"~
~1~
~$MYAH_UAC$~
~~
~~
~SKLICENSEIDFORMATTED~
~TRUE~
~~
~Set Variable~
~{7B657F6C-FC03-4DD1-A895-03E5347F4DC4}~
~SKLICENSEIDFORMATTED$MYAH$MYAH$FALSE~
~~
~Set Variable~
~{EA162093-2334-4ED7-8C0F-857C960C9BFD}~
~SKLICENSEID$MYAH$MYAH$FALSE~
~1111~

This works off of process exit codes where 0 is success and anything else is an error or invalid.

Francesco, could you make sure regex pattern matching is on the roadmap for future versions of InstallAware? This issue was way harder to solve than it should have been. Also, InstallShield has regex pattern matching support in its InstallScript language so this is something InstallAware should have to be competitive and make more complex deployments easier.

FrancescoT
Site Admin
Posts: 5361
Joined: Sun Aug 22, 2010 4:28 am

Re: Is there a way to run regex expressions on a variable?

Postby FrancescoT » Fri Mar 11, 2016 1:38 pm

I'll forward your request to our dev team.

Thanks!

Regards
Francesco Toscano
InstallAware Software

White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Publications - http://www.installaware.com/publications-review.htm
InstallAware Help -F1 anywhere in the InstallAware IDE


Return to “Technical Support”

Who is online

Users browsing this forum: No registered users and 137 guests