Posts: 7
Threads: 6
Joined: Feb 2011
Reputation:
0
02-24-2011, 10:39 PM
(This post was last modified: 02-24-2011, 10:41 PM by sravsand.)
There is a message on a webpage like Rs.4500.00/- (here there is no space between Rs and value and /- and it is a dynamic value, it may displays big number like RS340067.23/-)
How to retrieve only value without Rs. and /-
Thanks inadvance
Sandeep
Posts: 1,003
Threads: 1
Joined: Jul 2009
Reputation:
5
02-25-2011, 05:21 AM
Same stuff in a better way,
Numric = Split(Split(myVar,"Rs.")(1),"/-")(0)
Basanth
Give a fish to a man and you feed him for a day..Teach a man how to fish and you feed him for life.
Posts: 1,003
Threads: 1
Joined: Jul 2009
Reputation:
5
03-09-2011, 12:01 PM
Depends on where you want to use. In the above scenario replace is cumbersome because you want to replace multiple values. while split would simply tear the rest and give you what you need at one shot.Moreover, when you split you can reuse the other part( which would be in the array) while replace, just replaces the data.
Basanth
Give a fish to a man and you feed him for a day..Teach a man how to fish and you feed him for life.
Posts: 1,003
Threads: 1
Joined: Jul 2009
Reputation:
5
03-11-2011, 05:18 PM
The lines of code matter a big deal for a efficient execution.
Basanth
Give a fish to a man and you feed him for a day..Teach a man how to fish and you feed him for life.
Posts: 40
Threads: 1
Joined: Feb 2011
Reputation:
0
03-11-2011, 11:58 PM
Lines of code are not the only measure of a solution. Accuracy, flexibility, ease of understanding are important as well. Regular expressions are great for dealing with ambiguity in data. Regular expressions are quite flexible and can match many variations on a data "theme". However, regular expressions often do not do as well in the "ease of understanding" area as other solutions, and, as you pointed out, they may not be as efficient as other solutions.
We run our test sets overnight, unattended. For us, speed of execution is secondary. What does the poster plan to do with the data once it is parsed? Write it to another file? That is much, much slower than the regular expression and so the regular expression is a smaller percentage of the total execution time.
I am not arguing that a regular expression is the best or only solution here, but it is a good solution if the data format is varied as the examples suggest. If the data is NOT as varied as the examples suggest (i.e., there are typos in the example), then a regular expression would be overkill - like bringing in the USS Enterprise to kill a mouse.
It does provide more information to the poster about ways to tackle the problem and, hopefully, expands the poster's knowledge of QTP a little.
Posts: 1,003
Threads: 1
Joined: Jul 2009
Reputation:
5
03-12-2011, 08:57 AM
Knowledge shating wise good thought, though precision in answer is of utmost concern. The above problem is simply achieved by split a one liner then a whole junk of regularly expressioned syntax. Not necessary. Maybe helpful for a different post.
Oh.. I almost forgot, automation was brought forth to cut down the manual execution speed and if you are running scripts overnight not being bothered about the speed then it is time to think what you can improve. Not every company would want a setup like yours.
Basanth
Give a fish to a man and you feed him for a day..Teach a man how to fish and you feed him for life.
Posts: 5
Threads: 0
Joined: Aug 2010
Reputation:
0
03-21-2011, 04:08 PM
Hi Friends,
See.. Forum is basically for sharing knowledge.. People want to get different kind of answers, to improve themselves. I learned from regular expression post (Thanks for that, really a good work), as i dont have much exposure to it.
We all are already aware of more LOC need more execution time, there is nothing to say about this explicitly.
Instead of climbing to the single solution, be prepare to experiment different solutions. Thats a good way of learning..