How to disable regular expressions in a text? - Printable Version +- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums) +-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP) +--- Forum: UFT / QTP Regular Expressions (https://www.learnqtp.com/forums/Forum-UFT-QTP-Regular-Expressions) +--- Thread: How to disable regular expressions in a text? (/Thread-How-to-disable-regular-expressions-in-a-text) |
How to disable regular expressions in a text? - ttralor - 02-27-2013 Hello. I define an object with the next property and value: Code: "innertext:=jfjfjfj*.(fff)" What i tried is placing a backslash before all special characters but this is a lot of work. Is there another way i can prefent QTP to find the regular expressions? I want that QTP sees the value as only text, how can i do that? RE: How to disable regular expressions in a text? - ravi.gajul - 02-27-2013 Hi, Please use the below function. It receives a normal string and returns the equivalent string in regular expression Code: Function NormalizeString(OrgStr) RE: How to disable regular expressions in a text? - ttralor - 02-27-2013 Hello Ravi, Thank you for your answer but i do not get it worked. What i did, is adding the next line to your function: TempStr = Replace(TempStr, "$", "\$") I did this because the $-sign is also a character wich is used as a regular expression, which can cause my problem, i think...? Then i started this in QTP: Code: Function NormalizeString(OrgStr) DEPART Frankfurt to Acapulco3/27/2013SELECTFLIGHTDEPARTSTOPS Blue Skies Airlines 360 5:03non-stopPrice: \$270 (based on round trip) Blue Skies Airlines 3617:10non-stopPrice: \$271 (based on round trip) Pangaea Airlines 3629:17non-stopPrice: \$274 (based on round trip) Unified Airlines 36311:24non-stopPrice: \$281 (based on round trip) Ik put this string into this code: Code: If Browser("Welcome: Mercury Tours").Page("Select a Flight: Mercury").WebTable("html tag:=TABLE", "Index:=8", "column names:=DEPART Frankfurt to Acapulco.*","innertext:=DEPART Frankfurt to Acapulco3/27/2013SELECTFLIGHTDEPARTSTOPS Blue Skies Airlines 360 5:03non-stopPrice: \$270 (based on round trip) Blue Skies Airlines 3617:10non-stopPrice: \$271 (based on round trip) Pangaea Airlines 3629:17non-stopPrice: \$274 (based on round trip) Unified Airlines 36311:24non-stopPrice: \$281 (based on round trip)").Exist(1) Then When i remove the innnertext object property i get an "OK". When i use GetROProperty to get the innertext value it is exactly like i did use it, but why do i get no match? Whats wrong in? DEPART Frankfurt to Acapulco3/27/2013SELECTFLIGHTDEPARTSTOPS Blue Skies Airlines 360 5:03non-stopPrice: \$270 (based on round trip) Blue Skies Airlines 3617:10non-stopPrice: \$271 (based on round trip) Pangaea Airlines 3629:17non-stopPrice: \$274 (based on round trip) Unified Airlines 36311:24non-stopPrice: \$281 (based on round trip) RE: How to disable regular expressions in a text? - ravi.gajul - 02-28-2013 There could be other elements with same innertext.It would easy identifying the root cause if you could post the source code. RE: How to disable regular expressions in a text? - ttralor - 03-01-2013 This is my code: Code: If FlightFinderPag.WebTable("html tag:=TABLE", "Index:=8", "column names:=DEPART Frankfurt to Acapulco.*","innertext:=DEPART Frankfurt to Acapulco3/1/2013SELECTFLIGHTDEPARTSTOPS Blue Skies Airlines 360 5:03non-stopPrice: \$270 (based on round trip) Blue Skies Airlines 3617:10non-stopPrice: \$271 (based on round trip) Pangaea Airlines 3629:17non-stopPrice: \$274 (based on round trip) Unified Airlines 36311:24non-stopPrice: \$281 (based on round trip)").Exist(1) Then I investigated the WebTable an see that the same textvalue is also in the "outertext" property, can this be a problem? When i run my QTP script without the "innertext" i got an "OK" message. RE: How to disable regular expressions in a text? - ttralor - 03-06-2013 Yess after applying the last post, it works now. Thanks all! RE: How to disable regular expressions in a text? - Staff - 07-05-2013 Please ensure to include your code between [code] tags while asking or replying to questions. I have done this for you for this time. |