cancel
Showing results for 
Search instead for 
Did you mean: 

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

Contributor

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

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
5 REPLIES 5
Regular Contributor

Re: What is the tilde (~) character doing in regular express

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.
Remember:Questions are more important than answers.
The answer is 42 I'm a ninja!
Moderator

Re: What is the tilde (~) character doing in regular express

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
Temil Sanchez
Ready API Product Owner
Contributor

Re: What is the tilde (~) character doing in regular express

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?
Not applicable

Re: What is the tilde (~) character doing in regular express

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
Contributor

Re: What is the tilde (~) character doing in regular express

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

How did you find out, if you don't mind me asking?
New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors