Is it possible to escape parameters/variables included in a regex? [message #1078346] |
Fri, 02 August 2013 18:33  |
Eclipse User |
|
|
|
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 #1081723 is a reply to message #1080735] |
Wed, 07 August 2013 11:53   |
Eclipse User |
|
|
|
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.
|
|
|
|
Powered by
FUDForum. Page generated in 0.05099 seconds