Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Ways to perform extraction
#1
Solved: 10 Years, 8 Months, 3 Weeks ago
Can anybody tell how can we extract the current page and total pages value from the expression "Page 4 of 15"? One of the ways that i can think of is using split function but what can be the other ways of doing it?
Reply
#2
Solved: 10 Years, 8 Months, 3 Weeks ago
Are there any ideas to share by anybody?
Reply
#3
Solved: 10 Years, 8 Months, 3 Weeks ago
Hi AAB,

We can do it using regular expression too. Checkout the below code

Code:
input = "Page 22432 of 201222122"

Set objRegExp = New RegExp
objRegExp.Pattern = "[^A-Za-z ]\d*"
objRegExp.Global = True
Set Numbers = objRegExp.Execute(input)
msgbox Numbers.count
For I = 0 to Numbers.Count-1
    If I = 0 Then
        msgbox "Current Page Number: " & Numbers(I)
    ElseIf I = Numbers.Count-1 Then
        msgbox "Total Number of Pages:" & Numbers(I)
    End If
Next
Set Numbers = Nothing
Set objRegExp = Nothing

Let me known if you have any questions.
Thanks,
SUpputuri
Reply
#4
Solved: 10 Years, 8 Months, 3 Weeks ago
Hi supputuri,
Thanks for your help.It gave me another way to look at these matching/extraction issues.
Then i Tried this:
strlocation="D:\Documents and Settings\Desktop\New Folder"
Objective: To extract the folder name and the file path from the above location.
For the folder name i tried the following code:
'***********************************
Code:
Set obj=New Regexp
obj.pattern="[A-Z a-z]*$"
obj.global=True
Set num2=obj.execute(d)
msgbox num2.count
For i=0 to num2.count-1
    msgbox num2(i)

Next
'**********************************
Here the problem that i came across is that if i use the pattern as "[A-Z a-z]*$" then it gives two values in the match collection returned by Execute which are :"New Folder" and "".
So then i changed the pattern to "[A-Z a-z ]*$" and it gave me the correct result but the question is by looking at the input it seems that no additional space is there then why is it required in the regular expression?Please clarify.
Reply
#5
Solved: 10 Years, 8 Months, 3 Weeks ago
Hi I did not find any difference by using the specified patterns.

but change the obj.global = False we will get the correct value.
Thanks,
SUpputuri
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Alternate ways to input data Silpa 7 5,046 03-09-2012, 09:28 AM
Last Post: Silpa
  Perform Action on Browser using only VBScript bfakruddin 2 2,606 09-08-2010, 06:57 PM
Last Post: cdesserich
  How to perform the Filter action in excel using vb script? venkatbatchu 6 30,905 10-08-2009, 03:05 PM
Last Post: venkatbatchu
  How many ways we can use external XL sheet data import in to runtime datatable govqa 1 3,248 02-18-2009, 11:09 PM
Last Post: sreekanth chilam

Forum Jump:


Users browsing this thread: 1 Guest(s)