Page 1 of 1
Is there a way to run regex expressions on a variable?
Posted: Mon Aug 06, 2012 2:04 pm
by norbertjurkiewicz
I'd like to validate and reformat user input to make valid strings. The parse utility isn't up to the par.
Re: Is there a way to run regex expressions on a variable?
Posted: Tue Aug 07, 2012 10:17 am
by FrancescoT
Dear User,
Actually string parse operations are only available the Parse String command.
Otherwise you should write some custom component as a DLL.
Regards
Re: Is there a way to run regex expressions on a variable?
Posted: Fri Mar 11, 2016 12:00 pm
by chaoix
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.
Re: Is there a way to run regex expressions on a variable?
Posted: Fri Mar 11, 2016 1:38 pm
by FrancescoT
I'll forward your request to our dev team.
Thanks!
Regards