18 January 2026:
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
How to use regular expression in a script
Hi Narayan,
Please let me know how to use regular expression for this case:
_click(_link("linkname[2]"));
The number in the square braces is changing sometimes it 1 or 2 or 3.
Actually ' linkname ' is the name of the link which I have to click, in some places of application it is concatenated with number like [1] or [2] or [3].
so I should send the link name in a variable and concate with this changing number,
var $LINKName = " linkname ";
var $linkToClick = $LINKName +"["+[0-9]];
>I have tried this expression,but its not working
_click(_link($linkToClick));
Please let me know how to use regular expression for this case:
_click(_link("linkname[2]"));
The number in the square braces is changing sometimes it 1 or 2 or 3.
Actually ' linkname ' is the name of the link which I have to click, in some places of application it is concatenated with number like [1] or [2] or [3].
so I should send the link name in a variable and concate with this changing number,
var $LINKName = " linkname ";
var $linkToClick = $LINKName +"["+[0-9]];
>I have tried this expression,but its not working
_click(_link($linkToClick));
This discussion has been closed.
Comments
Is the link itself named linkname[2] in your application or is Sahi identifying it as linkname[2] while the link is just linkname?
If it is the first case, you can use If you want to concatenate a string and then do the same thing Regards,
Narayan
Thank You. But the link does not appear like that. SAHI is recognizing the link as _link("_linkname[1]") with the no. being different every time. I tried the above suggested two methods. But it is not recognized. Please help.
I could you please let me know how to use the regular expression in SAHI
var $sAcctType = "*Savings*" //The constant value is "Savings" at run time it was " 12312312 Savings"
_setSelected(_select("listAccounts"), $sAcctType );
Above statement doesnt work
Thanks in advance
Seems like there is a bug in Sahi which is preventing use of RegExp in _setSelected.
To fix it,
Open sahi/htdocs/spr/concat.js
Look for 3 lines below that you will see
Change it to
Restart Sahi, and clear your browser cache or force refresh the page.
Then you can use:
I will add the fix in the next build. Thanks for pointing it out.
Regards,
Narayan