String manipulation: Upper case with chemicals

Hello community,

I have a list of chemicals and want to write the first letter in capitals. However, this does not work for chemicals, which beginn with alpha, beta, gamma and or with numbers. Examples are

ethanol -> Ethanol (That´s easy, here it is the first letter)
1,4-butanediamine -> 1,4-Butanediamine
β-cyclodextrin -> β-Cyclodextrin

How could I solve this?

Thanks in advance!

1 Like

Hi @Alkaline and welcome back to KNIME forum,

Please check this expression in the String Manipulation node and let me know if it works as expected:

join(regexReplace($column1$, "[a-z]", ""), capitalize(regexReplace($column1$, "[^a-z]", "")))

:blush:

2 Likes

Hi,

thank you very much for your quick reply. Unfortunately, it did not work. The chemical names are quite complex and for some I had additional “-”. I will give a more detailed answer with some examples later.

2 Likes

Hi there @Alkaline,

give examples that represent possible formats of chemical names and I’m sure @armingrudd will come up with a right regex :wink:

Br,
Ivan

2 Likes