- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- Installshield 2019 regex at user input
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
Hi,
is it possible to create a validation of user input, for example by using regex in order to define the user input format?
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
Hi @kalu91 ,
You can use VBscript function in your installscript codefor regex validation.Snippet would be:
function NUMBER ValidateString(szString,szPattern)
OBJECT oRegEx, oMatch;
NUMBER nRet;
begin
//try to create the RegEx object
try
set oRegEx = CreateObject("VBScript.RegExp");
catch
MessageBox("CreateObject Failed- "+ Err.Decription, SEVERE);
endcatch;
oRegEx.Pattern = szPattern;
oRegEx.Global = 1; //set to 1 to find all matches in the string
//set to 0 to find only the first match
try
set oMatch = oRegEx.Execute(szString);
catch
MessageBox("CreateObject Failed- "+ Err.Decription, SEVERE);
endcatch;
nRet = oMatch.Count;
return nRet;
end;
Attaching sample .rul file for your reference as an attachment.
Thanks,
Jenifer
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
Hi @kalu91 ,
You can use VBscript function in your installscript codefor regex validation.Snippet would be:
function NUMBER ValidateString(szString,szPattern)
OBJECT oRegEx, oMatch;
NUMBER nRet;
begin
//try to create the RegEx object
try
set oRegEx = CreateObject("VBScript.RegExp");
catch
MessageBox("CreateObject Failed- "+ Err.Decription, SEVERE);
endcatch;
oRegEx.Pattern = szPattern;
oRegEx.Global = 1; //set to 1 to find all matches in the string
//set to 0 to find only the first match
try
set oMatch = oRegEx.Execute(szString);
catch
MessageBox("CreateObject Failed- "+ Err.Decription, SEVERE);
endcatch;
nRet = oMatch.Count;
return nRet;
end;
Attaching sample .rul file for your reference as an attachment.
Thanks,
Jenifer
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
Thank you very much!
![](/skins/images/D60DF682EA37BF37032955CE10F3F0BB/responsive_peak/images/icon_anonymous_message.png)