Regex
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Regex
Hi,
I was trying to implement something similar to the following https://support.smartbear.com/testcomplete/docs/scripting/regular-expressions.html
var regEx3 = /;(\r\n)+function/g;
var ReplacementLines = ";\r\n\r\n//A helper routine\r\nfunction";
var test1 = "function Foo(Param1)";
var test2 = test1.replace(regEx3,ReplacementLines);
but it does not give me the result as expected.
var test = "class=organizationAgentGridInfoRightColumn_Text12345";
var regEx = /<=organizationAgentGridInfoRightColumn_Text>.*/gi;
test = aqString.Replace(test,regEx,"abc");
Not sure what I am doing wrong. Is my regex wrong?
Solved! Go to Solution.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi aa1
Can You write more about this one? I think i can help You but i need more information.
For what for You need this? excel file? script routine?
what exactly do You want to replace and what is the complete form of the string?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Wamboo,
Thank you for the reply. I need it for automation script. I am using test complete to compare two html files - actual vs. expected. But there are some of the lines that I would like to ignore. So I want to use regex to find those lines and replace with a whitespace or some characteres so that the testcomplete passes the test. Right now I drilled down to very simple expression:
Example: If i try regex tester such as http://regexstorm.net/tester, , it shows 1 match but test complete says 0 match for the following so I am assuming regex dont work the same way as it normally does in test complete.
var test1 = "agent_1a2b3c_LangPref_0"; var regEx = "(?<=agent_).*?(?=_)"; var ppp = aqString.StrMatches(regEx,test1);
Test complete gives ppp = false which means it did not find any match. I dont seem to understand why. You have any ideas?
Regards,
aa
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi again,
Furthermore, looks like testcomplete has its own non native regex methods. So I was trying those but that did not take me anywhere either.
For example:
var testString = "agent_1d74901d5"; var testRegex = /\agent\_\a/; var re = new RegExp(testRegex); var rr = re.test(testString);
I dont understand why rr is false. Is that not how you would specify the regex?
thanks
aa
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @aa1,
If you compare web pages, I recommend that you refer to the following article to learn more about the Web Comparison Checkpoint:
https://support.smartbear.com/testcomplete/docs/testing-with/checkpoints/web-comparison/about.html
This is a built-in TestComplete's feature that may help you.
If you are looking for something else, please take a look at the following article explaining how to use regular expressions:
https://support.smartbear.com/testcomplete/docs/scripting/regular-expressions.html
Tanya Yatskovskaya
SmartBear Community and Education Manager
