# RegexReplace

**URL:** <https://forum.knime.com/t/regexreplace/74857>\
**Category:** KNIME Analytics Platform\
**Created:** [October 30, 2023, 2:02pm UTC](https://forum.knime.com/t/regexreplace/74857 "2023-10-30T14:02:27Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![knimerin](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/k/ba9def/32.png) [@knimerin](https://forum.knime.com/u/knimerin)\
**Post date:** [October 30, 2023, 2:02pm UTC](https://forum.knime.com/t/regexreplace/74857/1 "2023-10-30T14:02:27Z")

</div>

Hi, I am trying to find a regexpReplace statement to remove a dot followed by numbers.

I tried several things but it is too heavy for me. I tried  
`regexReplace($myString$, "(.*[0-9])\..*", "$1" );`

![image](https://forum-cdn.knime.com/uploads/default/original/3X/3/3/3370f0004ae6198ece90a8f134713258c128c4cd.png)

---

<div class="post-metadata">

**Author:** ![gonhaddock](https://forum-cdn.knime.com/user_avatar/forum.knime.com/gonhaddock/32/35425_2.png) [@gonhaddock](https://forum.knime.com/u/gonhaddock)\
**Post date:** [October 30, 2023, 2:43pm UTC](https://forum.knime.com/t/regexreplace/74857/2 "2023-10-30T14:43:57Z")

</div>

Hello @knimerin  
There are several ways to achieve the result without regex.

```auto
regexReplace($user pain$, "[.]\\d+", "")

```

If you want to handle it as a number; you can use a ‘String to Number’ and a ‘Math Formula’ node afterwards:

```auto
floor($user pain$)

```

As a text, you could also use a ‘Cell Splitter’ node with a dot as delimiter; retaining $user pain\_Arr[0]$ column.

BR

---

<div class="post-metadata">

**Author:** ![knimerin](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/k/ba9def/32.png) [@knimerin](https://forum.knime.com/u/knimerin)\
**Post date:** [October 31, 2023, 2:21pm UTC](https://forum.knime.com/t/regexreplace/74857/3 "2023-10-31T14:21:10Z")

</div>

Thanks for this solution. Worked pretty well. Is there also a regexReplace to get the last part of a string which is structured with “/” like:

DepartmentA\GroupB\MemberC

to get the MemberC? Note that it can have more ore less than 3 structures, like:

DepartmentA\MemD

---

<div class="post-metadata">

**Author:** ![gonhaddock](https://forum-cdn.knime.com/user_avatar/forum.knime.com/gonhaddock/32/35425_2.png) [@gonhaddock](https://forum.knime.com/u/gonhaddock)\
**Post date:** [October 31, 2023, 2:42pm UTC](https://forum.knime.com/t/regexreplace/74857/4 "2023-10-31T14:42:56Z")

</div>

Hi @knimerin

> [@knimerin](#):
>
> DepartmentA\GroupB\MemberC

You can test:

```auto
regexReplace($text$, ".*\\\\(.*)", "$1")

```

it will return: “MemberC”

BR

---

<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:** [November 7, 2023, 2:43pm UTC](https://forum.knime.com/t/regexreplace/74857/5 "2023-11-07T14:43:02Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
