Hey,
I have a whole sentence and I want to extract from it one statistic - any number that is always after the word “number”,
I tried to do it by System.Text.RegularExpressions.Regex.Match (name, “^ [\ d] +”). ToString
And it failed
Can I have some help, please?
Thanks!!!
@tamar.m
as a first shot have a look here:
maybe it need some adoptions between number (the word) and the number (digit) spaces etc.
I tried to like that too
I’ll send you the sentence and see if you can build me a little example: “שמספרו: 2388484 בדרך לישראל”
I need help
@tamar.m
have a look here
it seems to work if we do take care about the right to left direction
u can send me it in sequence.
Thank u
i have done in the watch box
have a look here:
regex.Match("שמספרו: 2388484 בדרך לישראל", "(?<=: )\d+",RegexOptions.RightToLeft)
ensure following:
kindly note: “(?<=: )\d+” in RegexWorld this pattern is looking right from : for a digit. with the changed text direction it finds now the numbers left from :
First thing thanks!
I think you did not fully understand me,
I have a variable that has values on both sides but always on the right side of the divider there is the word “numbered” and on the left side of the number there are more values, I only need to pull the figure with the divider itself
As I sent you in the picture:
The blue: the word “numbered”:
The yellow is the number itself that I want to extract:
The red is the rest of the sentence that appears on the left side of the number I want to pull out.
all the sentence I have it in a variable and I want to extract part of the sentence just the number
@tamar.m
the problem is that this foreign language blocks me for further implementations (right to left direction)
but as you can see above and described the regex / patterns can handle this with the leftToRight option
(it was showcased with looking to right anchor but executed to left)
so just enhance the pattern and define the other groups
As an alternate maybe this also works:
And extracting the number only:
so now you have different options and can work on these different approaches:
- anchored on a particular word/token
- groups with numbers in the middle
- number only extraction
But my sentence is much longer I can not do it by places I want to do REGEX that will look for me a number after a certain word,
The value I want to extract is on the right side of the word
kindly note:
the problem is that this foreign language blocks me for further implementations (right to left direction)
i cannot enter / work with these foreign characters / copy paste part of the blocks is failling etc.
(?<=: )\d+” in RegexWorld this pattern is looking right from : for a digit. with the changed text direction it finds now the numbers left from
with this particular word you can use to achnor it and looking to one direction. looking to other direction use YourPatternForTextToRetrieve(?=YourAnchorTerm)
Have you tested to separate them into different variables?
InputString = "שמספרו: 2388484 בדרך לישראל"
Pattern = "(?<=שמספרו[ :]+)\d+"
Number = RegEx.Match(InputString, Pattern, RegexOptions.RightToLeft).Value
it looks good,
But I did not understand where I put the pattern
Can you send me a file of the exercise please?
Thanks
See the attached file: ExtractNumberRegEx.xaml (5.1 KB)
Excellent !! It works!!!
Thank you all!!!
Now something a bit similar but different, if I want to check if next to a number there are spaces or other numbers and not the number 1 which is just one value how do I do that?
Good to hear that it’s working. I don’t understand your second question. Could you give a couple of examples with both input strings and then the expected output?
Hi @tamar.m,
Coincidentally, I am also doing a similar logic.
I’d like to share that you can do this easier and faster with the current Regex Builder Wizard of Matches
activity.
I reused @ptrobot’s ExtractNumberRegEx.xaml (7.6 KB) to insert the solution. Hope it helps!
You can read more about this here
Yes ,
1234557 1 63611838
I want only 1 that he has no number or lettars after him.
Thank u
נשלח מסמארטפון ה-Samsung Galaxy שלי.
-------- הודעה מקורית --------
מאת: ptrobot via UiPath Community Forum uipath@discoursemail.com
תאריך: 15.10.2020 09:26 (GMT+02:00)
אל: Tamar Markowitz Tamar.M@hms.co.il
נושא: UiPath Forum [Build/Activities] How to extract a value on the left side of the variable
[https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/ptrobot/45/175001_2.png] ptrobothttps://forum.uipath.com/u/ptrobot Robot Master
October 15
Good to hear that it’s working. I don’t understand your second question. Could you give a couple of examples with both input strings and then the expected output?
If you only want to match a single digit, use \b\d\b
If you want to match a single 1 then use \b1\b
Ok
If I want it to be after the word “numbered” but without dots ( how do I change it?
Usually you would do something like this for left-to-right languages: (?<=Number[: ]+.*)\b\d\b
But I don’t think it will work for you since you are having a mixture of left-to-right and right-to-left characters. Maybe some RegEx gurus familiar with regular expression for Hebrew text can chime in.