# RegEx Question about Rule Based Filter

**URL:** <https://forum.knime.com/t/regex-question-about-rule-based-filter/6877>\
**Category:** KNIME Analytics Platform\
**Created:** [October 23, 2014, 11:36am UTC](https://forum.knime.com/t/regex-question-about-rule-based-filter/6877 "2014-10-23T11:36:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![RolandGrund](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/r/ce7236/32.png) [@RolandGrund](https://forum.knime.com/u/RolandGrund)\
**Post date:** [October 23, 2014, 11:36am UTC](https://forum.knime.com/t/regex-question-about-rule-based-filter/6877/1 "2014-10-23T11:36:32Z")

</div>

Dear all,

by the help of the Rule Based Filter node I'm trying to get only rows where a specific string starts with exact three capital letters plus a dash ("-") followed by an arbitrary number of other characters (should be easy)

However, the following expression does not return any row although there are hundreds of possible candidates, e.g. BMW-4, REN-Clio, ...

$ItemsString$ MATCHES "^[A-Z]{3}\-"&nbsp; =\> TRUE

(with "Include TRUE Matches" Option set).

I tried this also on a regex page (http://www.regexe.de/) and got the right results

Any ideas ? Thx in advance ...

&nbsp;

---

<div class="post-metadata">

**Author:** ![thor](https://forum-cdn.knime.com/user_avatar/forum.knime.com/thor/32/4_2.png) [@thor](https://forum.knime.com/u/thor)\
**Post date:** [October 23, 2014, 2:12pm UTC](https://forum.knime.com/t/regex-question-about-rule-based-filter/6877/2 "2014-10-23T14:12:44Z")

</div>

MATCHES tries to match the whole string and not only parts of it. Therefore you need to add ".\*" at the back of your pattern.

---

<div class="post-metadata">

**Author:** ![aborg](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/a/c89c15/32.png) [@aborg](https://forum.knime.com/u/aborg)\
**Post date:** [October 23, 2014, 2:17pm UTC](https://forum.knime.com/t/regex-question-about-rule-based-filter/6877/3 "2014-10-23T14:17:33Z")

</div>

As I remember in prototype versions there were a method called CONTAINS with regular expressions, that would work for your attempt. With MATCHES, you should use something like the following (assuming no new lines):

```
$ItemsString$ MATCHES "^[A-Z]{3}\-.*"  => TRUE
```

---

<div class="post-metadata">

**Author:** ![RolandGrund](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/r/ce7236/32.png) [@RolandGrund](https://forum.knime.com/u/RolandGrund)\
**Post date:** [October 23, 2014, 3:34pm UTC](https://forum.knime.com/t/regex-question-about-rule-based-filter/6877/4 "2014-10-23T15:34:48Z")

</div>

Thanks, thor, aborg - that worked !!!

---

<div class="post-metadata">

**Author:** ![system](https://forum-cdn.knime.com/uploads/default/original/1X/ab3ccf34482a0329361734a18199390177204f15.png) [@system](https://forum.knime.com/u/system)\
**Post date:** [June 23, 2023, 8:23pm UTC](https://forum.knime.com/t/regex-question-about-rule-based-filter/6877/5 "2023-06-23T20:23:52Z")

</div>


