What is the tilde (~) character doing in regular expressions

Originally posted by ChristianB on January 24, 2014

Hi all!

I know soapUI follows the Java style RexExp constructs, as documented here:
http://www.jdocs.com/javase/7.b12/java/ … ttern.html
http://support.smartbear.com/viewarticle/55518/

I was looking at the regular expressions used in the Global Sensitive Information Tokens preferences:

I know and understand that the (?s) flag is used, so that whitespace matches include line breaks (DOTALL flag: http://www.jdocs.com/javase/7.b12/java/ … L#F-DOTALL ), as was explained here: viewtopic.php?t=588

But what I don’t understand is why the tilde is included in all of those regexp. It doesn’t show up in either soapUI’s regex documentation - or Java’s.

I’d be grateful for any hints and explanations…

Best regards,

Christian

Originally posted by PaulDonny on January 24, 2014

Somebody please correct me if I am wrong (I am decent with regexp but it’s been many years since I used PERL and was able to just run off expressions all day long) but I think it’s essentially notifying the system that the regexp expression starts there.

Originally posted by TSanchez_1 on January 24, 2014

Hello,

I did some the tilde represents a unary operation that performs logical negation on each bit. I found a stackoverflow link that may be able to help, please see below.

http://stackoverflow.com/questions/1483 … -does-mean

Regards,
Temil

Originally posted by ChristianB on January 24, 2014

Hi Temil, I’m not sure that’s it, as it appears inside the regular expression matcher. If it was in front of it (i.e. outside the delimeters), I think it would act a lot like an exclamation mark (!), turning true (1) into false (0) and vice versa, I guess…

PaulM, I don’t think it’s a delimiter. If it was, surely it should be on both sides of the matcher, shouldn’t it?

Originally posted by VinayMachamraj on March 10, 2014

Hi Christian,

The table show two columns:

  1. The token itself can either contain a plain string or a regular expression prefixed with a tilde sign (to separate it from a plain string)
  2. A description that will be shown in the Security Log if the corresponding token is found.

For example on Plain String: It would be like this in those two columns,

  1. abc@langTag - this not a regular expression.
  2. The description to the sting I have give is a string value to a String variable or parameter.

For example on non-plain String : It would be same as the screen shot you have provided with ~ tilde sign means it is not a plain String with value it is regular expression to be followed for that string variable or parameter.

Regards,
Vinay Machamraj

Originally posted by ChristianB on July 16, 2014

Thank you, Vinay, that’s extremely useful to know.

How did you find out, if you don’t mind me asking?