Forum Discussion

mathotp's avatar
mathotp
Occasional Contributor
6 years ago

regular expressions not working in javascript using clickItem

Hi everyone,

 

I'm have some trouble with the regular expression in javascript while using clickItem.

 

I'm using this code: 

Aliases.HealthWin32.MainForm.MDIClient.frmLiveMessages.pnlClient.SplitterMain.TRzSplitterPane.pnlTreeview.tvMessages.ClickItem("regexp:\|Boîte de réception.*\|eHealth Box.*)");

and I'm always getting the following error:

The TreeView node 'regexp:' not found.

I did try a few thing but nothing does it.

Does anyone have any ideas, am I doing somthing wrong ? 

As per the documentation, what I'm doing seems to be correct.

 

thank you

Phlippe

  • Hi Phil,

     

    a) Thank you for the update;

    b) Just recollected after reading your message that in some cases it was required to enclose regexp subexpressions with parenthesis in order they match (this is documented but I don't have a link at hand). So you may try this:

    .tvMessages.ClickItem(/(\\|Boîte de réception.*)\\|(\\|eHealth Box.*)/);

     

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    > As per the documentation, what I'm doing seems to be correct.

    Can you provide a link to the help topic?

    I am not sure that regular expressions are supported to specify the full path to some tree view item.

     

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Well... Thank you for the link... It looks that it should be possible indeed...

    Just two ideas to check:

    a) Duplicate slashes in the regexp string. I.e.:

    .ClickItem("regexp:\\|Boîte de réception.*\\|eHealth Box.*)");

     

    b) Try to use JavaScript-specific syntax (see code sample in the "Specifying Variable Parts in Object Captions" paragraph of the referenced help topic). Like this:

    .ClickItem(/\\|Boîte de réception.*\\|eHealth Box.*)/);

     

    Does this help?

     

    P.S. There seems to be non-paired closing parentheses in your code sample. May it be another problem?

    .ClickItem("regexp:\|Boîte de réception.*\|eHealth Box.*)");

     

    Shouldn't it be either

    .ClickItem("regexp:\\|Boîte de réception.*\\|eHealth Box.*\\)");

    or just

    .ClickItem("regexp:\\|Boîte de réception.*\\|eHealth Box.*");

    ?

     

    • mathotp's avatar
      mathotp
      Occasional Contributor

      Hi Alex,

       

      the regex seems to be working but it can't find the TreeView, but this is another story :)

      I use the following: 

      Aliases.HealthWin32.MainForm.MDIClient.frmLiveMessages.pnlClient.SplitterMain.TRzSplitterPane.pnlTreeview.tvMessages.ClickItem(/\\|Boîte de réception.*\\|eHealth Box.*/);

       

      Thank you for your help, and thank you for pointing out the ')' whicih was not escaped :p

      • mathotp's avatar
        mathotp
        Occasional Contributor

        Hi Alex,

         

        The regular expression wasn't  working at all, I always had an error stating that it couldn't find the expression and the searched term was: '<This is blank>', empty string, which was not correct, so I ended up using wildcards instead

         

        ClickItem("*eHealth Box*")
        

        And this worked like a charm.

         

        Thank again for your help

         

        Phli