Hello friends,
Why does this delete last character if it is ‘0’?
regexReplace($Sales Order Item$, “0$”, “”)
If I need to delete first character what should I write here?
I mean is it as in SQL %, _ ?
Guru, please help to understand) Thank you!
Hello friends,
Why does this delete last character if it is ‘0’?
regexReplace($Sales Order Item$, “0$”, “”)
If I need to delete first character what should I write here?
I mean is it as in SQL %, _ ?
Guru, please help to understand) Thank you!
The $
character is Regex for end-of-line. So the pattern matcher is looking for a sequence with a zero and end-of-line.
If you want to remove the first character of the line you can use ^.
.
This matches ^
as the start of the line, and .
which is any character.
Your expression would become: regexReplace($Sales Order Item$, “^.”, “”)
The full list of Java Regex patterns is here (note that Regex has different flavours depending on the programming language):
https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html
You can practice Regex expressions using the following website to confirm what works:
Hello,
Your function replaces the last 0 appearing in your string because regexReplace is replacing the 0 with an empty string “”.
Your function reads 'replace Sales Order Item’s last 0 with “” ’
If you need more examples of how to use regex in KNIME, refer to Various Examples of Regex in KNIME – KNIME Hub
and the link Pattern (Java Platform SE 7 ) provided by @DiaAzul
thanks!
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.