Remove all strings after certain symbol - syntax in String manipulation Node

Hello, could you please help me with syntax in string manipulation node in order to exclude all symbols after certain symbol f.i:
AB TRADE GK/MOSKVA
AB TRADE GK/MOSKVA
AIS/DOLGOPRUDNIY
AIS/DOLGOPRUDNIY
AIS/DOLGOPRUDNIY
AIS/DOLGOPRUDNIY
AIST/SPB
I would like to exclude all letters after symbol / like AB TRADE GK/MOSKVA to get only AB TRADE GK
AIS/DOLGOPRUDNIY to get AIS etc
Thank you in advance!

Hello @Averin7777
Looking at your data sample, ‘Cell Splitter’ node can be a candidate. You can configure it by defining “/” as delimiter.

BR

Thank you very much, this node you recommended is quite simple solution :clap: :+1:

1 Like

@Averin7777
Just for the records. A single step solution (with no column rearrange needed) would be to code regex in a ‘String Manipulation’ node:

regexReplace(
	regexReplace($column1$, "^(.*/).*", "$1")
	, "[^a-zA-Z0-9]+", "")

However I always recommend to use node approaches that can be understood by oneself, then you can fix it in the case of new requirements, modifications…

BR

thanks for the string manipulation syntax, but I would like to use this for another task similar:
TOPPERR (AB TRADE GK/MOSKVA) to get only TOPPERR
TOPPERR (AB TRADE GK/MOSKVA)
AGENT P FINISH (AIS/DOLGOPRUDNIY) AGENT P FINISH
and when I change only from “^(./).”, “$1”) to “^(.().”, “$1”) it does not work it excludes all letters??

Hi @Averin7777

Try this one:

regexReplace(
	regexReplace($column1$, "^(.*\\().*", "$1")
	, "[^a-zA-Z0-9]+", "")


it shows me this error

You are missing a bracket closing in row 5. I still have to resolve the StripEnd issue…

thanks a lot for the effort, if you can solve this would help me a lot, I am new user of knime, like to learn this syntax

it works thanks but is the option to let the original spaces, so far it works like this
AGENT P FINISH (AIS/DOLGOPRUDNIY) => AGENTPFINISH
need to be like this AGENT P FINISH if possible

@Averin7777
Now it works, I was missing the space after the 9 as well…

strip(
	regexReplace(
		regexReplace($column1$, "^(.*\\().*", "$1")
	, "[^a-zA-Z0-9 +]", "")
)

:+1:t3:

1 Like

It works perfect, many thanks once again, I can now study the syntax conditions.

1 Like

Hello, may I ask you for advice in string manipulation node,
for a syntax to get from string [P1-18] to P01 18 ??
thank you very much in advance!!

Hello @Averin7777 and sorry for my late answer.

Test this code in a ‘Regex Split’ node:
^\[(.*?)[-](.*?)\]$

image
Some extra manipulation may be needed to pass from “P1” to “P01”, is it still needed?

A bit of casuistic can be required as: P12 → P12, P3 → 03 , I mean, is it always a two digit code after the P? can it be 3 at some circumstances?

BR

2 Likes

Hello, thank you very much for your response, I have got a solution from other guy: here is the solution from him, it might inspire you :

1 Like

I really admire guys like you how they are familiar with this composed syntax! :clap: :+1:
but need another more help need get from [FEB18] to Feb-18, can you help if possible?
Thank you so much!

Hello @Averin7777

An update with all finished solutions:


20220517_regex_split_averin7777_v3.knwf (15.2 KB)

image

join(
	$split_0$
	, lowerCase($split_1$)
	, "-"
	, padLeft($split_2$, 2, "0")
	)

BR

1 Like

Hello,
could you please help me with syntax in String manipulatio node to get from Jul 2019 to JUL 19 ??
Thank you!!

I have just figured out on my own: upperCase(replace($ColumnNames$," 20" , " ")) it is working

1 Like

Hello @Averin7777
That’s an easy one. ‘String Manipulation’ node

upperCase( $text$ )

BR