Why does this regular expression work in Regex Tester but not in LibreOffice Find and Replace?

I am using the following regular expression:

 .*@cs\s

On Regexpal my regex does what it is suppose to, however on LibreOffice is doesn’t.

The Regex above should match the following sample cases:

anytext@cs
orthistexttoo@cs

It however should not match cases where the is text following the “cs” part. The Regex I created above according to RegexPal works, however in LibreOffice nothing is found. Here is an example of a case that should not be matched:

butNotThisText@cs.IhavestuffAfterTheCS.

Am I doing something wrong here?

The LibreOffice/OpenOffice “flavour” of regex doesn’t know your \s, as you have discovered. According to Regular-Expressions.info:

\s stands for “whitespace character”. Again, which characters this actually includes, depends on the regex flavor. In all flavors discussed in this tutorial, it includes [ \t\r\n\f]. That is: \s matches a space, a tab, a line break, or a form feed.

If that is indeed what you want, you’ll need to use this for your LibO Calc (or Writer) regex:

.*@cs([:space:]|$|\t|\r)

At least in my little test it seemed to behave the way you want. Further on LibO/OO regex:

I am just going for an effect where it only selects entries matching the beginning case and NOTHING after the “cs” part. Some rows I have include something like cs.extra.com or something along this things which I do not want to return as matches. They must specifically end with a “cs”

So … did the solution I suggested work for you? or no? You could also try .*@cs(?!.), using a negative lookahead which appears to be supported, but it will not find “text@cs ”, i.e., “cs” followed by a space.