Hello Guys,
I have following string I need to capture the amount before the string and after the string. The string is fixed. Please consider white spaces.
1234 I FEEL HAPPPY 123456.23
Thanks in advance
Hello Guys,
I have following string I need to capture the amount before the string and after the string. The string is fixed. Please consider white spaces.
1234 I FEEL HAPPPY 123456.23
Thanks in advance
Hi @RPA2,
Regex for first part → regex101: build, test, and debug regex - then use index 0 for it
Regex for second part → regex101: build, test, and debug regex
Thanks Pablito for quick reply.
I have to consider the fixed string also. Because only that is the key object I have form the entire text file. So the text file consists many numbers and amounts and if I use only number reading pattern it will come up with all the numbers in the text file which I don’t want.
So we have to create regex that can consider the fixed string.
Please give more example. From mentioned string you wanted to extract number before and after the text what actually I’ve done.
Hello Pablito,
I am using this sort of text file. from which I am getting two values
1 BANK DRAFT PAYMENTS APPLIED FOR A TOTAL OF 123.456
so I am capturing 1 and 123.456
Thanks
Buddy @RPA2
kindly follow the below steps that could resolve your issue buddy
so the
out_value_1 = 1
out_value_2 = 123.456
Thats all buddy you are done
Kindly try this and let know buddy @RPA2
Cheers
Buddy @RPA2
waht was the error buddy
can you get your mouse to the blue symbol at the right top of the activity buddy
Cheers
Hi @RPA2
Try using below code
Value1 (String) = item.split({“BANK DRAFT PAYMENTS APPLIED FOR A TOTAL OF”},StringSplitOptions.None)(0).ToString.Trim
Value2 (String) = item.split({“BANK DRAFT PAYMENTS APPLIED FOR A TOTAL OF”},StringSplitOptions.None)(1).ToString.Trim
Hey @RPA2
You can use Below Regex pattern for this - [0-9]*\.?[0-9]+
Reference Link - regex101: build, test, and debug regex
Sample - RegexPatternForStringOperationSample.xaml (6.0 KB)
Regards…!!
Aksh
Hello Akshay Regex bulder is 2019 version while I have 2018.
Hey @RPA2
Nothing will affect just use pattern in Pattern property. and pass input string and output variable
Regards…!!
Aksh
Hello ALL RPA GURUS,
Thanks you so much for your efforts in resolving this issue.
I am uploading the screenshot how I did it so anyone can take a look if need.
Buddy it should be like this @RPA2
you were almost right, but need some corrections buddy
item_string.Split(“BANK DRAFT PAYMENTS APPLIED FOR A TOTAL OF”,StringSplitOptions.None)(0).ToString.Trim
item_string.Split(“BANK DRAFT PAYMENTS APPLIED FOR A TOTAL OF”,StringSplitOptions.None)(1).ToString.Trim
Cheers @RPA2
Hi
If you just want to use a Regular expression to get the values then you can use the ones below:
1 BANK DRAFT PAYMENTS APPLIED FOR A TOTAL OF 123.456
To get the first number (1)
\d+(?=(\D+ \d+\.\d+))
To get the string (BANK DRAFT PAYMENTS APPLIED FOR A TOTAL OF)
(?<=\d+ )\D+(?=( \d+\.\d+))
To get the second number (123.456)
(?<=\d+ \D+ )\d+\.\d+
Using RegEx is considerably less complicated than using string functions.
Hope this helps