Ask a Question

reguler expressions

NisHera
Valued Contributor

reguler expressions

I need to detect following error message

 

Error_in_Validating_Fields_Aggregated_Tax_Calc_and_Tax_Averaging_cannot_be_combined_on_the_same_Instance_

 

to make sure I'm getting correct message I have to make sure the error string contains
"Error", "Aggregate", "Tax_Averag ", "combin " in any order
How do you do it using non-native reguler expressions

 

8 REPLIES 8
TanyaYatskovska
SmartBear Alumni (Retired)

Hi NisHera,

 

The following regular expression should work for you:

(?=.*Error)(?=.*Validating)(?=.*Tax_Averag)(?=.*combin).*
---------
Tanya Yatskovskaya
SmartBear Community and Education Manager



Hi Tanya,

 

Is this type of regex supported by the aqObject.CompareProperty method?

I tried

(?=.*project)(?=.*successfully).*

instead of previously used

(project)|(successfully).*(project)|(successfully)

and CompareProperty() failed to match with the

Project saved successfully

string.

 

Sample code (executed in the Evaluate dialog):

aqObject.CompareProperty("Project saved successfully", BuiltIn.cmpMatches, "(?=.*project)(?=.*successfully).*", False, BuiltIn.lmNone)

returns False instead of expected True

 

Been able to use this type of regex with CompareProperty and the like methods would be of great convenience, so I really hope that it was me who did something incorrect.

 

Could you please comment?

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================

Hi Tanya,

Unfortunatly is does not work at all .

Even just following is not working

(?=.*combin).*

 Also what dose "="  means ?

could not find equal sign in any regex litreture.

why do you use "?" which means 0 or 1 time? shouldn't be "+" which mean 1 or more times

Hi,

 

'?=' is a lookahead assertion. Unfortunately, it is not supported by all regex engines and this was the reason for my question of whether or not TestComplete supports it.

E.g.:

http://stackoverflow.com/questions/19896324/match-string-in-any-word-order-regex

http://stackoverflow.com/questions/13911053/regular-expression-to-match-all-words-in-a-query-in-any-...

http://stackoverflow.com/questions/4389644/regex-to-match-string-containing-two-names-in-any-order

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
NisHera
Valued Contributor

seems "lookahead assertion" dosn't supported by TCSmiley Frustrated

djadhav
Regular Contributor

If we know for sure that the words would not be repeated, then this will work:

 

(Error|Aggregate|Tax_Averag|combin).*(Error|Aggregate|Tax_Averag|combin).*(Error|Aggregate|Tax_Averag|combin).*(Error|Aggregate|Tax_Averag|combin)

Hi,

 

> [...] this will work [...]

Yes (http://community.smartbear.com/t5/Desktop-Testing/reguler-expressions/m-p/111227#M4700)with two notes:

a) (Due to some TC regex specifics?) instead of

(Error|Aggregate|Tax_Averag|combin).*(Error|Aggreg​ate|Tax_Averag|combin).*(Error|Aggregate|Tax_Avera​g|combin).*(Error|Aggregate|Tax_Averag|combin)

it must be

(Error)|(Aggregate)|(Tax_Averag)|(combin).*(Error)|(Aggreg​ate)|(Tax_Averag)|(combin).*(Error)|(Aggregate)|(Tax_Avera​g)|(combin).*(Error)|(Aggregate)|(Tax_Averag)|(combin)

 

b) This makes regex expression much longer and far less obvious as for its logic.

 

So it looks like that support for regex lookahead assertions in TC would be a great thing...

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
TanyaYatskovska
SmartBear Alumni (Retired)

Hi All,

 

 


@AlexKaras wrote:

Hi Tanya,

 

Is this type of regex supported by the aqObject.CompareProperty method?


 

Alex, as far as I know, our Team has improved the XPath support in the latest TestComplete versions. If this assertion doesn’t work for you in TestComplete 11.20, I recommend that you submit a feature request to implement this. You can do this here. Guys, please vote up the feature request to increase its rating.

 

 

 

Update: I see that @NisHera has already submitted the suggestion to implement this functionality. Feel free to add your vote there here: http://community.smartbear.com/t5/TestComplete-Feature-Requests/regex-lookahead-assertions/idi-p/111...

2016-01-06_115959.png

 

---------
Tanya Yatskovskaya
SmartBear Community and Education Manager



cancel
Showing results for 
Search instead for 
Did you mean: