Micro Focus QTP (UFT) Forums
" " in search 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: " " in search text (/Thread-in-search-text)

Pages: 1 2


" " in search text - bostonma - 01-31-2009

Hi,

I have text something like this :
Code:
<td width="33" background="/images/main_nav_bg.gif"><img src="/images/gnav_div.gif" width="2" height="11" vspace="6" hspace="14" />
I need to store this text and verify it against actual value.
Now when I try to save this in a variable
say txt = above string,I get error message (expected end of statement) as there are many " " characters in the string itself and in QTP by default if we use " " then it is considered as comment.
can someone please help me how can I store one big sentence in a variable that contains " " within it.


RE: " " in search text - Ankur - 01-31-2009

Are you sure you have to verify ALL the above tags?

if yes you can extract them from their respective GetRoProperties


RE: " " in search text - bostonma - 02-04-2009

Yes,unfortunately I have to store all these variables.
This is working by placing " infront of each ", means like this (width=""2"").
Now the problem I am facing is retrieving them back to normal means(width = "2").
I tried using Replace(Var,"""",""") but this is not working.
Any other ideas?

What I am trying to do is above text is all static so I need to store static content ,add some values and then verify it against dynamic values displayed.Any help is appreciated.


RE: " " in search text - manojith1984 - 02-04-2009

Hi,
Using Replace(Var,"""",""") will not work as ' " ' is a metacharacter. Hence try converting ' " ' to ASCII value (i think the ASCII value of " is 34 and use Chr(34))

Code:
vReplace = Chr(34) & Chr(34)
vValue = Replace(Var,vReplace,Chr(34))

*this code may require some chage.


RE: " " in search text - bostonma - 02-04-2009

Hi Manojith,

I tried using the above code, tried with some modifications as well using chr(39) too, but did not work.Thanks in adavance for your help.

Code:
sString1 = "height=""1"
vReplace = Chr(34) & Chr(34)
vValue = Replace(sString1,vReplace,Chr(34)).



RE: " " in search text - Prafulla - 02-04-2009

Hi there,

try to escape double quotes by using double quote.
Code:
a= "<td width=""33"" background=""/images/main_nav_bg.gif""><img src=""/images/gnav_div.gif"" width=""2"" height=""11"" vspace=""6"" hspace=""14"" />"

msgbox a



RE: " " in search text - bostonma - 02-04-2009

Hi Prafulla,

Please see my above question.
I am trying to remove the extra double that I entered.


RE: " " in search text - Prafulla - 02-04-2009

Hi...

i think u want that 33 in double quote...i.e."33" for that u need to treat " as special char..rt..n for tht u hv to use it like ""33""...
plz let me know if its clear


RE: " " in search text - bostonma - 02-04-2009

Prafulla,

It is the oppsoite of what you understood I guess.

I have a long string(for now I am using an exSmile
Code:
String1 = "height=""11"
In this case I want output as below with escape characters removed.Hope it is clear.
Code:
String1 = "height="11"



RE: " " in search text - papu - 03-10-2009

supose u have a string say String1 = "height=""11" and u want String1 as "height="11" .If thi is the case then use the below code

Code:
String1 = "height=""11"
str = replace(String1,chr(34)&chr(34),chr(34))