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

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?

edit retag reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Alex Kemp close date 2016-02-26 09:55:27.602927

Sort by » oldest newest most voted

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:

more

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"

( 2014-06-25 01:39:47 +0100 )edit

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.

( 2014-06-25 09:32:27 +0100 )edit