Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Jubula » Is it possible to escape parameters/variables included in a regex?
Is it possible to escape parameters/variables included in a regex? [message #1078346] Fri, 02 August 2013 18:33 Go to next message
David Hickernell is currently offline David Hickernell
Messages: 61
Registered: October 2012
Member
Hello all,

I am trying to pass a regular expression as a parameter to a test case, and the regular expression string is meant to include the literal content of a parameter of the enclosing test case. The trouble is, some possible values of the included parameter have characters in them that are significant to RE parsers. I am trying to figure out a way of including an escaped version of the parameter in the expression, but not escaping the '=' at the beginning of the parameter reference.

Any ideas? Or do I just have to include already-escaped versions of all the parameter values as another column in my test data?

Thanks!
Re: Is it possible to escape parameters/variables included in a regex? [message #1080735 is a reply to message #1078346] Tue, 06 August 2013 06:22 Go to previous messageGo to next message
Alexandra Schladebeck is currently offline Alexandra Schladebeck
Messages: 1092
Registered: July 2009
Senior Member
Hi,

I'm having a bit of trouble envisaging it without an example, but the gist is that you can use backslashes (often multiple) as escape symbols, and also single quotes around strings to mark them as verbatim.

Hope that helps!
Alex
Re: Is it possible to escape parameters/variables included in a regex? [message #1081723 is a reply to message #1080735] Wed, 07 August 2013 11:53 Go to previous messageGo to next message
David Hickernell is currently offline David Hickernell
Messages: 61
Registered: October 2012
Member
Well, here's the general situation. Test case A has a parameter, LANGUAGE, and test case A executes test case B, which requires a regular expression string. I want to include =LANGUAGE in the RE, but one of the possible values for LANGUAGE is "C++". This produces an error when included in the RE. However, if I put quotes around =LANGUAGE in the RE, then instead of including the literal contents of parameter LANGUAGE, the RE string will simply include the literal string "=LANGUAGE".

So what I wanted was for the RE to contain =LANGUAGE in such a way that the contents of LANGUAGE are taken literally in the RE. What I am now doing as a workaround is just defining another column of data, LANGUAGE_ESC, that contains escaped versions of the LANGUAGE values, and using =LANGUAGE_ESC in the RE instead. I was curious if there was a simpler way to do it.
Re: Is it possible to escape parameters/variables included in a regex? [message #1086403 is a reply to message #1081723] Wed, 14 August 2013 02:59 Go to previous message
Alexandra Schladebeck is currently offline Alexandra Schladebeck
Messages: 1092
Registered: July 2009
Senior Member
Hi,

Thanks for the description. When I used the string : c\\+\\+ as the language, that worked for me.

Hope that helps,
Alex
Previous Topic:Can't connect to AUT using Jenkins...occasionally
Next Topic:convert integer to corresponding ascii value
Goto Forum:
  


Current Time: Fri Jul 25 09:50:35 EDT 2014

Powered by FUDForum. Page generated in 0.03596 seconds