Results 1 to 12 of 12

Thread: Regular expression

  1. #1
    Junior Member
    Join Date
    Jun 2008
    Answers
    6

    Regular expression

    How to use the Regular expression? Please give an example. In which circumstances we can use it? Please help


  2. #2
    Contributing Member
    Join Date
    Feb 2008
    Answers
    36

    Re: Regular expression

    Hi There,

    Regular expressions are used when the values of the objects are varying(dynamic data).

    For example when you login to yahoo mail with user name "XYZ", on the top you see "Welcome XYZ" if you login as "ABC" the screen display "Welcome ABC"

    You can define a regular expression as:

    Dim regEx, Match, Matches ' declare variable
    RegExpTest = "" ' initial the result variable
    Set regEx = New RegExp ' create a regular expression object
    regEx.Pattern = "[a-zA-Z0-9 ]" ' set its pattern
    regEx.IgnoreCase = True ' set case insensitivity

    Here "Pattern" will be your regular expression and you can use it wherever the data is dynamic.

    I hope it's clear, do get back incase you still have doubts.

    Regards,
    Tina Mahajan.


  3. #3
    Junior Member
    Join Date
    Jun 2008
    Answers
    6

    Red face Re: Regular expression

    Hi Tina,

    U so lovely ! Thank you soo much for ur reply.

    THis is clear with me. I have one more doubt - When we are going to parameterize we wil get a screen with a checkbox for Regular expression. My doubt is how to use and when to use that regular expression check box. You have given the coding. My doubt is here..

    Please gimme the answer for this also


  4. #4
    Contributing Member
    Join Date
    Feb 2008
    Answers
    36

    Re: Regular expression

    Hi there,

    I didnt get your question.

    When you parameterize, u get a "Value Configuration Options" screen. There is no checkbox here. There are RadioGroups.

    Using parameteriztion you are providing different values that are to be entered in the form of data table. You dont have to use regular expressions here.


    Regards,
    Tina Mahajan

    Last edited by Tina Mahajan; 06-05-2008 at 12:48 AM.

  5. #5
    Junior Member
    Join Date
    Jun 2008
    Answers
    1

    Re: Regular expression

    hi tina
    i am nean u w in qtp. can u lemme know how to capture movie clip of result. in qtp 9.2.

    thanks in advns


  6. #6
    Junior Member
    Join Date
    Jun 2008
    Answers
    6

    Smile Re: Regular expression

    Hi Tina,

    I will clear my question with an example.

    Record any link. Goto Object Repository->Click on the specified link ->On the right side of the repository u can see the 'Test Object Details' - below that 'name' and 'value'. Click on the text(for example)-In the value column you can see the text of the link and the right side <#> . Click on that - you will be in "Value Configurations Options" box. There u can see the check box "Regular expression". ( )

    My question is how it will be useful in that condition?

    Love

    Euro


  7. #7
    Contributing Member
    Join Date
    Feb 2008
    Answers
    36

    Re: Regular expression

    Ok got it now!

    When you select constant and check on the regular expression,

    You can simply substitute a value with regular expression like [a-z][A-Z][0-9]
    in the textbox infront of constant radiobutton.
    So this will refer to any link having alphanumeric value for name property.

    But when you are parameterizing, I dont think you need regular expression sice you can provide all the desired values in the data table.

    Regards,
    Tina Mahajan.


  8. #8
    Junior Member
    Join Date
    Jun 2008
    Answers
    6

    Re: Regular expression

    Hi Tina,

    Still I am blank in some where:

    I am giving these lines : Dim regEx, Match, Matches ' declare variable
    RegExpTest = "" ' initial the result variable
    Set regEx = New RegExp ' create a regular expression object
    regEx.Pattern = "[a-zA-Z0-9 ]" ' set its pattern
    regEx.IgnoreCase = True ' set case insensitivity

    in a new script what will happen? how can I use that?

    For example if i need to use the a-z , how to use. can u plz give a clear example..

    Sorry..am asking the question like a stupid


  9. #9
    Contributing Member
    Join Date
    Feb 2008
    Answers
    36

    Re: Regular expression

    Hi there,

    Its ok to ask if u dont understand.

    Well,
    Now lets assume a scenario:

    You open a google search page and use object Spy on it.
    The name property for Browser has value "Google"

    Now type "abcd" in the search textbox and click on Google Search button.
    Use object Spy on this new page
    The name property for Browser has value "Abcd - Google Search"

    So you see depending on what you enter in the textbox the name property of your Browser changes.

    So instead of changing the name everytime u declare a regular expression and use it as a value for that name property.

    eg.

    Dim regEx, Match, Matches ' declare variable
    RegExpTest = "" ' initial the result variable
    Set regEx = New RegExp ' create a regular expression object
    regEx.Pattern = "[a-zA-Z0-9]" ' set its pattern
    regEx.IgnoreCase = True ' set case insensitivity

    ' Global property is set to True to indicate the search applies
    ' to the entire string and not just the first one
    regEx.Global = True

    'Code to create description for Browser object.
    Set desc_BrowserProperty = Description.Create()
    desc_BrowserProperty("name").Value = Pattern
    desc_BrowserProperty("Class Name").Value = "Browser"
    desc_BrowserProperty("Index").Value = "0"

    In this eg i have created regular expression as Pattern. and used it as a value for name property.

    Hope that makes it clear.
    Feel free to ask in case of any more doubts.

    Regards,
    Tina Mahajan


  10. #10
    Junior Member
    Join Date
    Jun 2008
    Answers
    6

    Thumbs up Re: Regular expression

    Dear tina, thanks soo much.. So kind heart ! i have one doubt about base filter property in qtp: i know the info like : mandatory properties : class, label assistive property : x,y co-ordinates,enable,disable,height,width optional filter properties : location, index base filter properties : ---------------- can you give a help? thanks euro


  11. #11
    Junior Member
    Join Date
    Jun 2008
    Answers
    1

    Re: Regular expression

    thanks for answers


  12. #12
    Junior Member
    Join Date
    Jun 2008
    Answers
    6

    Re: Regular expression

    Hi Tina,

    R u there??


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact