SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 5 of 5
  1. #1
    Junior Member
    Join Date
    Oct 2007
    Posts
    16
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    how use regular expression in Script?

    Hi,
    I have an issue regarding Regular Expression.

    Im having an application which has listview in that some text Contents will be there i need to validate that word "Deployment" exist or not but as per the task it has done below

    Counts=Window("Maintain Development Environme").Dialog("Customize").WinList("Toolbars: ").GetItemsCount
    booval1=False
    For i = 0 to Counts-1

    If Window("Maintain Development Environme").Dialog("Customize").WinList("Toolbars: ").GetItemProperty(i, "text") = "Deployment" Then
    boolval = True
    boolval1 = boolval
    else
    boolval = False

    end if
    Next

    If boolval1 = True Then
    Msgbox " it exists"
    else
    msgbox " it doesnt"
    End If
    **************************************
    but the Problem is. It will check only for the Word "Deployment" but i need to validate that word which can be in any form but regular exp is not recognising properly (Directly by typing)

    say for an example if i give the value as ".*Deployment.*" its showing error

    Any Sugestion for the above to discuss,

    Prabhu R [img]/images/graemlins/confused.gif[/img]

  2. #2
    SQA Knight
    Join Date
    Jul 1999
    Location
    Grand Rapids, MI
    Posts
    3,727
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: how use regular expression in Script?

    [ QUOTE ]

    IF Window("Maintain ...")...GetItemProperty(i, "text") = ".*Deployment.*" THEN


    [/ QUOTE ]
    This is a vbScript syntax question and not a QTP question. You can't arbitrarily use a regular expression in any given expression. So the following will all fail:

    1. Yours above
    2. IF "foo" = ".*foobar.*"
    3. IF ".*foobar.*" = "foo"

    Rather you have to use the vbScript Regular Expression Object and its supporting methods to perform a regEx comparison. Online Help provides a rich set of entries that covers all things regEx, starting with the "Regular Expression" entry.

  3. #3
    Junior Member
    Join Date
    Dec 2007
    Posts
    4
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: how use regular expression in Script?

    Another solution to this if you can not get the Regular Expression working is to use the instr method

    dim objX: set objX = Window("Maintain Development Environme").Dialog("Customize").WinList("Toolbars: ")

    If(instr(1, objX.GetItemProperty(i, "text"),"Deployment")>0) Then
    .
    .
    .

    -----------------------------------------------------------
    DougH

  4. #4
    SQA Knight
    Join Date
    Jul 1999
    Location
    Grand Rapids, MI
    Posts
    3,727
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: how use regular expression in Script?

    Good reply Doug. I addressed the specific question while you addressed the general problem!

  5. #5
    Junior Member
    Join Date
    Oct 2007
    Posts
    16
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: how use regular expression in Script?

    Cool Doug it Helped me a lot you are simply the Great

    Thanks,

    Prabhu.R

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 11.54%
vBulletin Optimisation provided by vB Optimise v2.6.4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 12:36 AM.

Copyright BetaSoft Inc.