Micro Focus QTP (UFT) Forums
How to extract part of a string between two particular characters. - 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: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: How to extract part of a string between two particular characters. (/Thread-How-to-extract-part-of-a-string-between-two-particular-characters)



How to extract part of a string between two particular characters. - ACCBAJPA - 08-14-2013

Hi, I have taken the outerhtml of a dropdown present on my webpage, which has 14 questions. now I need to split the questions and take the ubound of the array to count the no of questions present. so I think in the below outerhtml I would need to extract the string between > and ?. how to go about it?/ please help.

Code:
<ul><li role="option" class="x-boundlist-item"><div id="ext-gen1100" class="uw-combo-option">What is the first name of your oldest nephew?</div></li><li role="option" class="x-boundlist-item x-boundlist-selected"><div id="ext-gen1099" class="uw-combo-option">What is the first name of the best man at your wedding?</div></li><li role="option" class="x-boundlist-item"><div id="ext-gen1098" class="uw-combo-option">What was the first name of your first boyfriend/girlfriend?</div></li><li role="option" class="x-boundlist-item"><div id="ext-gen1091" class="uw-combo-option">What was the first name of your first manager? (Enter full name of only)?</div></li></ul>



RE: How to extract part of a string between two particular characters. - Ankur - 08-14-2013

If you just want to count the number of questions -
  • Use GetROProperty to fetch the value of the items in dropdown. If for some reason it is not available then
  • You may use split function to split based on ? character . The number of questions would be UBOUND - 1 OR
  • Make use of instr function to locate ? character.



RE: How to extract part of a string between two particular characters. - ACCBAJPA - 08-14-2013

Hi, Ankur thanks for the response.

1- the object is not being recognized as weblist but a webedit. so I am confused how can i use GetROProperty("items count"),
2-also if i split the function using ? delimiter it slits the question having a condition with it in two parts, eg "What was the first name of your first manager? (Enter full name of only)" is a single question which gets split in two parts.


RE: How to extract part of a string between two particular characters. - ssvali - 08-15-2013

It will helpful if you share the properties and values by using Object spy


RE: How to extract part of a string between two particular characters. - ACCBAJPA - 08-16-2013

Hi, here are the object's properties :-
Code:
"Class Name:=WebElement",
"abs_x:=502",
"abs_y:=392",
"class:=list-ct",
"height:=257",
"html id:=ext-gen1034",
"html tag:=DIV",
"innerhtml:=<ul><li role=""option"" class=""x-boundlist-item""><div class=""uw-combo-option"">What is the first name of your oldest nephew\?</div></li><li role=""option"" class=""x-boundlist-item x-boundlist-selected""><div class=""uw-combo-option"">What is the first name of the best man at your wedding\?</div></li><li role=""option"" class=""x-boundlist-item""><div class=""uw-combo-option"">What was the first name of your first boyfriend/girlfriend\?</div></li><li role=""option"" class=""x-boundlist-item""><div class=""uw-combo-option"">What was the first name of your first manager\?</div></li><li role=""option"" class=""x-boundlist-item""><div id=""ext-gen1036"" class=""uw-combo-option"">What is the first name of your oldest niece\?</div></li><li role=""option"" class=""x-boundlist-item""><div id=""ext-gen1085"" class=""uw-combo-option"">What was the name of your first pet\?</div></li><li role=""option"" class=""x-boundlist-item""><div class=""uw-combo-option"">What is the first name of the maid of honor at your wedding\?</div></li><li role=""option"" class=""x-boundlist-item""><div id=""ext-gen1084"" class=""uw-combo-option"">Where did you meet your spouse for the first time\? \(Enter full name of city only\)</div></li><li role=""option"" class=""x-boundlist-item""><div id=""ext-gen1081"" class=""uw-combo-option"">What is the name of the first company you worked for\?</div></li><li role=""option"" class=""x-boundlist-item""><div id=""ext-gen1083"" class=""uw-combo-option"">What is your grandfather's nickname\?</div></li><li role=""option"" class=""x-boundlist-item""><div id=""ext-gen1080"" class=""uw-combo-option"">What was your favorite restaurant in college\?</div></li><li role=""option"" class=""x-boundlist-item""><div class=""uw-combo-option"">What street did your best friend from high school live on\? \(Enter full name of street only\)\?</div></li><li role=""option"" class=""x-boundlist-item""><div class=""uw-combo-option"">What was the first name of your favorite teacher in your final year of high school\?</div></li><li role=""option"" class=""x-boundlist-item""><div class=""uw-combo-option"">What was the name of the town your grandmother lived in\? \(Enter full name of town only\)\?</div></li></ul>",
"innertext:=What is the first name of your oldest nephew\?What is the first name of the best man at your wedding\?What was the first name of your first boyfriend/girlfriend\?What was the first name of your first manager\?What is the first name of your oldest niece\?What was the name of your first pet\?What is the first name of the maid of honor at your wedding\?Where did you meet your spouse for the first time\? \(Enter full name of city only\)What is the name of the first company you worked for\?What is your grandfather's nickname\?What was your favorite restaurant in college\?What street did your best friend from high school live on\? \(Enter full name of street only\)\?What was the first name of your favorite teacher in your final year of high school\?What was the name of the town your grandmother lived in\? \(Enter full name of town only\)\?",
"outerhtml:=<DIV class=list-ct id=ext-gen1034 style=overflow: auto;><ul><li role=""option"" class=""x-boundlist-item""><div class=""uw-combo-option"">What is the first name of your oldest nephew\?</div></li><li role=""option"" class=""x-boundlist-item x-boundlist-selected""><div class=""uw-combo-option"">What is the first name of the best man at your wedding\?</div></li><li role=""option"" class=""x-boundlist-item""><div class=""uw-combo-option"">What was the first name of your first boyfriend/girlfriend\?</div></li><li role=""option"" class=""x-boundlist-item""><div class=""uw-combo-option"">What was the first name of your first manager\?</div></li><li role=""option"" class=""x-boundlist-item""><div id=""ext-gen1036"" class=""uw-combo-option"">What is the first name of your oldest niece\?</div></li><li role=""option"" class=""x-boundlist-item""><div id=""ext-gen1085"" class=""uw-combo-option"">What was the name of your first pet\?</div></li><li role=""option"" class=""x-boundlist-item""><div class=""uw-combo-option"">What is the first name of the maid of honor at your wedding\?</div></li><li role=""option"" class=""x-boundlist-item""><div id=""ext-gen1084"" class=""uw-combo-option"">Where did you meet your spouse for the first time\? \(Enter full name of city only\)</div></li><li role=""option"" class=""x-boundlist-item""><div id=""ext-gen1081"" class=""uw-combo-option"">What is the name of the first company you worked for\?</div></li><li role=""option"" class=""x-boundlist-item""><div id=""ext-gen1083"" class=""uw-combo-option"">What is your grandfather's nickname\?</div></li><li role=""option"" class=""x-boundlist-item""><div id=""ext-gen1080"" class=""uw-combo-option"">What was your favorite restaurant in college\?</div></li><li role=""option"" class=""x-boundlist-item""><div class=""uw-combo-option"">What street did your best friend from high school live on\? \(Enter full name of street only\)\?</div></li><li role=""option"" class=""x-boundlist-item""><div class=""uw-combo-option"">What was the first name of your favorite teacher in your final year of high school\?</div></li><li role=""option"" class=""x-boundlist-item""><div class=""uw-combo-option"">What was the name of the town your grandmother lived in\? \(Enter full name of town only\)\?</div></li></ul></DIV>",
"outertext:=What is the first name of your oldest nephew\?What is the first name of the best man at your wedding\?What was the first name of your first boyfriend/girlfriend\?What was the first name of your first manager\?What is the first name of your oldest niece\?What was the name of your first pet\?What is the first name of the maid of honor at your wedding\?Where did you meet your spouse for the first time\? \(Enter full name of city only\)What is the name of the first company you worked for\?What is your grandfather's nickname\?What was your favorite restaurant in college\?What street did your best friend from high school live on\? \(Enter full name of street only\)\?What was the first name of your favorite teacher in your final year of high school\?What was the name of the town your grandmother lived in\? \(Enter full name of town only\)\?",
"type:=",
"visible:=True",
"width:=366",
"x:=502",
"y:=329"



RE: How to extract part of a string between two particular characters. - ACCBAJPA - 08-22-2013

anyone ??


RE: How to extract part of a string between two particular characters. - Ankur - 08-22-2013

Why aren't you using innertext to get the desired result?


RE: How to extract part of a string between two particular characters. - ACCBAJPA - 08-22-2013

ohh yes..thanks Ankur.