Hi, I need to split a filename into variables. Filename format: BC1234-ECS-xx-xx-bq-a-0011.pdf
Using the [Variable].split("-") gives me and array
[ "BC1234","ECS","xx","xx","bq","a","0011.pdf"]
How can i replace the " with nothing? and how do I take each element of the array.
I can do [variable].split(2), but that gives the first 2 elements.
I'd normally do something like skip(split(Variable),2),1) which gives the first 2 elements but skips the first. Then wrap a replace('"','') around it.
I can't find how this works in workato.
R
Roland Daane
said
about 3 years ago
I forgot to add a screenshoh how I've tried the exclude (which doesn't work yet)
S
Sachin Dalmia
said
about 3 years ago
Hi Roland -
I'll answer in two parts -
How do you replace `"` with nothing?
You can use `.gsub("\"", "")`. Idea is to escape the quotes.
How do you take each element of the array?
You can use indexing. Arrays in ruby follow 0-indexing.
For example ; To access 2nd element in an array [ "BC1234","ECS","xx","xx","bq","a","0011.pdf"], you'd write array[1].
To access range of elements (for example, 2nd, 3rd, and 4th element) in the same array, you'd write array[1..3]. Refer to this documentation for more details.
Roland Daane
Nesting functions
Hi,
I need to split a filename into variables.
Filename format: BC1234-ECS-xx-xx-bq-a-0011.pdf
Using the [Variable].split("-") gives me and array
[ "BC1234","ECS","xx","xx","bq","a","0011.pdf"]
How can i replace the " with nothing? and how do I take each element of the array.
I can do [variable].split(2), but that gives the first 2 elements.
I'd normally do something like skip(split(Variable),2),1) which gives the first 2 elements but skips the first. Then wrap a replace('"','') around it.
I can't find how this works in workato.