String Manipulation using RegEx

Hey Guys i wanna manipulate my string (path) and write it back to column.
The Problem is that i dont really get why my expression is not working.

regexReplace($Location$,(“[^s]+vjkre”)," ")

This is my input string C:\Users\dgd2\Desktop\zip-Dateien\Quelldateien\vjkre1906.20190702.134206500.xml

and i need this as output vjkre1906.20190702.134206500

How can i solve it ?

Thanks so far.
Philipp

Hi @PhilippBobo

Why not use a String Mainpulation node with:

substr($Location$, 0, lastIndexOfChar($Location$, ‘.’ ) )
or
replace($Location$, “.xml” , “” )

gr. Hans

2 Likes

regexReplace(substr($column1$, (lastIndexOfChar($column1$, '\\') + 1)), "\\.xml" , "")

2 Likes

Hi @PhilippBobo,

as the “regexReplace” funciton indicates, it replaces content. What is also worth to know is that, if it does not match, it returns the whole string.

In your case the RegEx should look like so:
regexReplace(replace($Location$, ".xml", ""), "^.* Quelldateien\W", "")

Edit: Adjusted to filter for the suffix. Though, i just recognized that by converting the string into URL and using, I think it was the Extract URI Info node, you get the file name too. That node can not be used if you have dots in the file name!

This will replace everything you do NOT want to be present afterwards. Please note that I deliberately included \W to make the function interoperable … working on Windows and Linux.

As a side note, you may use the String Replacer node. It works much better when lopping over various columns i.e. when using the Column List Loop Start.

Happy Kniming
Mike

2 Likes

Hi @PhilippBobo,

I see you have already got several solutions. Here is mine:
regexReplace($Location$, ".*\\\\(.*)\\.xml", "$1")

:blush:

3 Likes

Hi all,

Nice to see quite a few regex experts… :slight_smile:

Br,
Ivan

1 Like

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