SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 4 of 4
  1. #1
    Senior Member
    Join Date
    May 2003
    Location
    Austria
    Posts
    1,480
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    match(): Regular expression error: [ ] imbalance

    Sometimes strange problems occur that I've never seen before...

    As in this case, where a WinRunner error dialog appeared saying:
    Regular expression error: [ ] imbalance
    if (match(str1, str2) != 0)


    (the second line showed the code in which this error occured).

    Having a look at the values of str1 and str2, I saw that str2 contained a "[" without a "]".
    The problem is that an application error occured before, and as a result of it the variables str1 and str2 contained rubbish. But if the script would have been able to continue, the next test had had a chance to clean up and run properly.

    My question: Do you know a way of preventing WR from coming up with an error dialog when the regular expression in match() is not correct?
    I do not want to program a syntax check for regular expressions into all match()-statements in all scripts...

    Returning 0 (no match) in this case would be enough, wouldn't it?

    Regards,
    Juergen

  2. #2
    Moderator
    Join Date
    Mar 2002
    Location
    Tampa Bay
    Posts
    7,673
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: match(): Regular expression error: [ ] imbalance

    First I'm not surprised the script failed, Juergen. A syntax error (which, in effect this was) is not recoverable generally.

    I do not want to program a syntax check for regular expressions into all match()-statements in all scripts...
    <font size="2" face="Verdana, Arial, Helvetica">It seems like a design problem that you allow rubbish to end up in str2.

  3. #3
    SQA Knight
    Join Date
    Jun 2002
    Location
    Cupertino, CA, USA
    Posts
    2,164
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: match(): Regular expression error: [ ] imbalance

    I agree with Peter. I can understand rubbish ending up in str1, but not str2. The regular expression is usually fixed. Why would you have a dynamic regular expression? Can you describe in a broader sense how you define str1 and str2?

  4. #4
    Senior Member
    Join Date
    May 2003
    Location
    Austria
    Posts
    1,480
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: match(): Regular expression error: [ ] imbalance

    I have built some user defined functions that should do the same like a "normal" TSL function, but with the possibility of using regular expressions.

    Example: tab_select_item needs an exact match for the tabname, therefore I wrote a function tab_select_item_wc (wc = wildcards).
    This functions reads one tabname after the other and compares it against the input parameter of this function.
    The reason for developing this function was that our tabnames keep changing, if values within the tab are being modified, they get an asterisk at the end. I could have done this with using index(), but I wanted to make the function more flexible (and allow regular expressions), so I used match() instead.

    Example for this usage:
    tab_select_item_wc("tabObject", "[mM]yTab");

    That's the explanation why I have dynamic regular expressions.

    Now to the explanation why rubbish came into str2: I am testing a Java application, and have to use lots of java method calls to get specific values (in this case the name of the tab - str2). If the developers change the name of a method, my java method call will return rubbish.

    And if you didn't do enough exception handling (some sort of self-critics), it can happen that this rubbish will find its way into the match()-function...

    The thing that was annoying me was just the fact that WR will stop execution in this case and come up with an error dialog instead of reporting an error, returning an error code (or zero) and continue execution.

    But I guess I'll have to write a small regEx-syntax checker...

    Regards,
    Juergen

 

 

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 © 2017 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 © 2017 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 09:22 PM.

Copyright BetaSoft Inc.