Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Titan » Regular expression escaping in configuration file
Regular expression escaping in configuration file [message #1768347] Mon, 17 July 2017 17:40 Go to next message
Harald Welte is currently offline Harald WelteFriend
Messages: 50
Registered: July 2017
Location: Berlin, Germany
Member

I'm using Eclipse Titan 6.2.0 and am currently playing with the
TELNETasp TestPort. This port requires the user to specify the prompt
on the telnet server for use with "buffered" mode. This works fine for
a fixed prompt situation. For variable prompts (such as those that
change with context of where you are in the navigation of a MIB), one
can specify regular expressions, e.g. using "REGEX_PROMPTn" variables.

However, as soon as want to use the '\' escaping character to include
symbols like () or # in the prompt, the Titan test executor complains:

Parse error in configuration file `sysinfo/Test.cfg': in line 15, at or before token `\$': Invalid escape
sequence in string literal.

Can somebody explain to me what is the correct method to escape in
regex's spcified in the config file?
Re: Regular expression escaping in configuration file [message #1768462 is a reply to message #1768347] Wed, 19 July 2017 06:42 Go to previous message
Elemer Lelik is currently offline Elemer LelikFriend
Messages: 854
Registered: January 2015
Senior Member
Hi Harald,

Please try to double-escape (e.g. as in '\\$') the symbols in question;
Here's why: there are at least two parsers that will interpret your string:
the config file parser and the regexp parser of the TELNET port, each with a different mission and set of rules.
Some special characters ( "^", "$", "\", """ etc.) can be interpreted literally or as a control character and interpretation may be different from layer to layer.
For instance the first parser may recognize the special character \n as "newline" and send it as 0xd to the next parser ;
but it may not recognize \$ (it's not a C-style escape) and it may send it to the next parser as literal \ followed by literal $
However if you escape "\" (as in "\\$") this will force interpretation of "\$" as "end of line" regex and the first parser will send "\$" (as control character) to the next parser.
(This is a theoretical example, I did not check the Titan code, but this is a typical scenario on the web, making thousands of hacks possible :) )

I hope this makes sense

Please let me know if it works

Best regards
Elemer

[Updated on: Wed, 19 July 2017 09:06]

Report message to a moderator

Previous Topic:How to use a TTCN3-based library in other TTCN3 projects (Simple solution)
Next Topic: Support for JSON binary encodings in Titan: CBOR
Goto Forum:
  


Current Time: Sat Nov 17 17:39:57 GMT 2018

Powered by FUDForum. Page generated in 0.01576 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top