cancel
Showing results for 
Search instead for 
Did you mean: 

Regex

SOLVED
aa1
Contributor

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?

Tags (1)
1 ACCEPTED SOLUTION

Accepted Solutions
Community Manager

Re: Regex

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 Gorbunova
SmartBear Community Manager

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others.↓↓↓↓↓

View solution in original post

4 REPLIES 4
Community Leader

Re: Regex

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?

aa1
Contributor

Re: Regex

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

Highlighted
aa1
Contributor

Re: Regex

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

Community Manager

Re: Regex

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 Gorbunova
SmartBear Community Manager

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others.↓↓↓↓↓

View solution in original post

New Here?
Join us and watch the welcome video:
Watch the new Interview
Top Kudoed Authors