Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help Again with regular expression
#1
Solved: 11 Years, 3 Months, 3 Weeks ago
Hi, I need help with regular expression again. scenario is to handle dynamic date and time
Ex: 09/11/2012 9:10 AM

Another one is just 2 string
Ex : Grant Approved
Reply
#2
Solved: 11 Years, 3 Months, 3 Weeks ago
Hi Jinnah,

Date Regular Expression:

Format: MM/DD/YYYY

MM: (0[1-9]|1[0-2])
DD: (0[1-9]|1[0-9]|2[0-9]|3[0-1])
YYYY: ([0-9][0-9][0-9][1-9]|[1-9]000|[1-9][1-9]00|[1-9][1-9][1-9]0)
* Assuming that Max year is 9999

Time Regular Expression:

Here Max Time: 23:59:59 and Min Time: 00:00:00

Hours: ([0-1][0-9]|2[0-3])
Mins: ([0-5][0-9])
Secs: ([0-5][0-9])

| Choice between two lines
( ) Used to group multiple regular expressions
[-] To specify a range

Try this it may helpful...
I am not sure about the 2nd thing...

Regards,
Sibi C A
Reply
#3
Solved: 11 Years, 3 Months, 3 Weeks ago
Awesome! What if i need to combine both date and time ? What conjunction should be used? Thank you very much again.
Reply
#4
Solved: 11 Years, 3 Months, 3 Weeks ago
Ex1 : MM/DD/YYYY
Ex2 : Hours:Mins:Secs
Include the regular expressions instead of MM DD YYYY Hours Mins Secs.For Dynamic date use '/' (see Ex1) as conjuction.Like this, you can use conjuction ':' (see Ex2) in dynamic time.

Regards,
Sibi C A
Reply
#5
Solved: 11 Years, 3 Months, 3 Weeks ago
I actually need the whole date and time in one regular expression.
And I still have problem handling a text string like "negligent sale of goods and services"
Thanks for the help
Reply
#6
Solved: 11 Years, 3 Months, 3 Weeks ago
Code:
InjuredPerson=Browser("ClaimCenter_Br").Page("ClaimCenter_Pg").WebList("InjuredPerson_PIP").GetROProperty("selection")
If  InjuredPerson= "#8"Then
    Reporter.ReportEvent micPass,"Drop down value selected or new Injured Person is created(4)",""
    Call Logger(1,"Drop down value selected or new Injured Person is created")
    else
    Reporter.ReportEvent micFail,"Drop down value is not selected or new Injured Person is not created(4)",""
    Call Logger(2,"Drop down value is not selected or new Injured Person is not created")
End If

Number 8 is dynamic.

I tried "#[0-9]" "#[0-9]+" "#*" "#d\" "#d\+" None workd Except "#8".

I am facing same kind of problem in several places. Where only numbers get changed. Need solution badly.
Reply
#7
Solved: 11 Years, 3 Months, 3 Weeks ago
@ Jinnah,

You can not simply compare the regular expression using conditional statement.

Let me explain it to you.

Below are the basic steps that you need to follow.

1. You need to create an object of VbScript.RegExp
2. Assign the pattern you want to test.
3. Pass your string and check the result. It only returns true/False for successful/Unsuccessful results.

Let me give you one example.

Code:
Set RegEx = CreateObject("VBScript.RegExp")
RegEx.Pattern = "#[0-9]+"   //This is the pattern tht you need to write, here it is for "#8"
blnResult=RegEx.Test(strText) ' str text is the string that you want to check. as per your example here it is #8
If blnResult=True Then
'Pass
' Your reporter event
Else
'Fail
'Your reporter
End If
Set RegEx=Nothing

Let me know if you need more help.

Regards,
Ankesh
Reply
#8
Solved: 11 Years, 3 Months, 3 Weeks ago
Great! I will try it today. I will let you know.Hope it will work. Thanks buddy
Reply
#9
Solved: 11 Years, 3 Months, 3 Weeks ago
Hi Finally I could make it work Thanks buddy!
Code:
SelectionItem=Browser("").Page("").WebList("").GetROProperty("selection")

Set RegEx = CreateObject("VBScript.RegExp")
RegEx.Pattern = "#[0-50]+"
blnResult=RegEx.Test(SelectionItem)

If blnResult=True Then
Reporter.ReportEvent micPass,"Value selected from <ComplainingParty>",""
    Call Logger(1,"Value selected from <Allegations>")
    else
    Reporter.ReportEvent micFail,"Value not selected from <ComplainingParty>",""
    Call Logger(2,"Value not selected from <Allegations>")
End If
Set RegEx=Nothing


Thank you very very very much
Reply
#10
Solved: 11 Years, 3 Months, 3 Weeks ago
Glad that it worked for you. Smile
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Need Any digit in xpath path using Regular expression Priyam 1 3,495 10-05-2016, 11:05 AM
Last Post: Ankur
  Regular expression to read two words in lowercase, uppercase and with and without spa sarahq49 1 3,356 04-09-2015, 01:56 AM
Last Post: sarahq49
  Regular expression and script optimisation Padmavathy 1 3,825 03-30-2015, 11:46 AM
Last Post: supputuri
  Regular expression in descriptive programming testernc 1 16,571 12-08-2014, 06:38 PM
Last Post: anshika.agarwal
  need a regular expression. anu05446 0 3,121 11-26-2014, 03:00 PM
Last Post: anu05446

Forum Jump:


Users browsing this thread: 3 Guest(s)