I am trying the split the amount value using “EUR” from filename while splitting this i am getting some error please find all the screenshots arranged sequentially



Thanks in advance
I am trying the split the amount value using “EUR” from filename while splitting this i am getting some error please find all the screenshots arranged sequentially
Thanks in advance
Probably you are trying to access a position that does not exist in your array. What is file variable returning? Is it returning the correct name of your file?
Edit: Have you already tried this way: Split(file, “EUR”)(0).ToString ?
Try below.
yourResult = varStr.Split(new string[] { "EUR" }, StringSplitOptions.None)(1).ToString
Ignore my above comment
System.Text.RegularExpressions.Regex.Split(varStr,"EUR")(1).ToString
Yes, it is returning the file name
Again it is throwing error
It is also throwing error
@rsr.chandu - If you are looking to extract the last amount before the .pdf then you can use the below pattern…
System.Text.RegularExpressions.Regex.Match(YourFileName,"(?<=EUR\s+)[\d.,]+(?=.pdf)").value
You can assign this to a string value.
Please find the sample below:
Hi,
Can you share the above regex sample workflow (Sequence1.xaml) as a file?
Probably we need accurate string data.
Regards,
Hi,
Thank you for your sharing the file.
However, we need string data. So can you share the following file?(we need to know content of fn variable.)
Regards,
Hi,
Thank you for sharing the file.
I checked it using regex pattern which @prasath17 mentioned, and it works.
Sequence1.xaml (5.0 KB)
First, can you try the above sample?
Next, if it works, can you check is there any difference between the above filename and your filename using WriteLine activity to output filename?
Regards,
If it is a throwing error means the keyword is not present in the string or you are doing something wrong…Otherwise, it is impossible to throw errors.
I saw all the solutions and those are very nice but you need to put more effort to do the exception handling in either case.
Check IF EUR is present in the string before splitting the data.
If varStr.contains(“EUR”) then to split
I would suggest to go ahead with solution by @prasath17 if looking for amount and also REGEX expressions are more feasible than string operations
Е972 , 25040 , Rheinmetall Electronics GmbH, 06.01, ЕUR 266.677,29.pdf (22.4 KB)
Can you try this last one
@rsr.chandu …in your screenshot I could see - inside the square bracket right.? If yes it should be . Please use copy icon to copy the code and paste it. It should work.
Hi @rsr.chandu
In ‘f1’ assign, please change it as path.GetFileNameWithoutExtension(file)
in ‘f2’ assign, f1.Replace(“ЕUR”,“&”).Split("&"c)(1)
Note: f1 variable type should be array[string], f2 variable type should be string.
Thanks.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.