I have used OCR test result from an captcha image and stored the output as a string.
Now I need to extract the numerics and find the solution. Can someone help me how to achieve this?
I have attached a sample of question, here I need to find the middle number.
This question also can be find the 1st number, find the last number or find the total of those, or sometimes largest number or smallest number etc.
If you do have a definite list of Questions that is already known to appear, We could prepare the Logic for it by using the Switch Activity but if the question can be of any sorts, we would not be able to do it in a rule based manner.
Hi @Ranjit_Nayak1 , have you tried extracting the value via regular expressions? you can use “[0-9]” as the pattern to extract only the numbers from the text.
The result would be a collection of matches which you can iterate through.
And also for extracting number you can either use split or if the separators are changing then use regex \d+ which would also work as stated by @Balaji_Murugan
I have used flow decision and taken output as captcharesult for different captcha. I used just the below and was able to find smallest number, need to use the same process for others aswell. If we can simplify the below, please suggest.
I tried all above solutions couldn’t achieve, found my own solution for this as mentioned below, hope it helps others for such usecase if incase.
No need to use any loop here also, its so easy.
arr = String1.Split({“,”},StringSplitOptions.None) //this is to split with delimiter
arrInt= Array.ConvertAll(arr, function(str) cint(str.trim)) //this is to convert str array to int array for calculation
.
.
Then I can use as below:
addition= arrInt.Sum()
largestNo= arrInt.Max()
smallestNo= arrInt.Min()
firstNo= arrInt.First()
lastNo= arrInt.Last()
subtraction= arrInt.max()-arrInt.min()
middleNo= arrInt(1)