A question of string manipulation

#1

Hi there!

I have a string column including file location and date&time information.
Now I need to convert this string like the following image.

string%20convert

Please notice the Date&time part of the last 3 rows contains different hour expression (2 digit).

I tried a lot to use Column Expressions Node to handle this manipulation but not successful.
Could you please give some advice to this question?

Here you can find the sample data.
StringConvert.xls (27 KB)

Thanks in advance.

0 Likes

#2

Hi,

To get the format in “StringTo” column from the “String” column, use this expression in a String Manipulation node:
regexReplace($String$, ".*-", "")

If you want to use the Column Expressions node instead:
regexReplace(column("String"), ".*-", "")

Best,
Armin

4 Likes

#3

It worked! @armingrudd
Currently I don’t understand why it worked, need to study regex expression…

Thank you!

2 Likes

#4

.*- selects all the string before the dash character and the dash itself and since there are multiple dash characters in the string, everything to the last one is selected. If you put a caret “^” at the beginning of the regex ^.*- then it only selects the first match which means everything before the first dash and the first dash itself will be selected.

https://www.regular-expressions.info

:blush:

1 Like

#5

Thanks for your addition information. Completely understood! :blush:
I have also found some article on web for learning regex expression but it seems different in different tools :shushing_face:. I will read the link from you in advance.

Many thanks!

2 Likes