i had posted before this , it was to get numbers from a string with specific rules here is the link
Hi All ,
need ur help to only extract data using the regex with some use cases as below:
**Use case **
LOREM LS8515, WEN+ FEED, WATER (E570)
LOREM IPSUM 8515
LOREM IPSUM-8515
LOREM IPSUM8515
LOREM IPSUM8515 WATER2570
OUPUT NEEDED : 8515
Guys please note Lorem Ipsum can be any words or symbol thank you
Thank you guys
But now i want to get the words before the spesific number and it will ignore the spacing or symbol (" " or"," or ,β-β)
thank you
use cases example , the β is the output i want , thank you :
1.WILDUN DUMA 8515 β output : DUMA
2.WILWAL SE1865 GEN+ Feed, Food (N570) - > output : SE
3.WILWAL AI1865 GEN+ Feed, Food (N570) β output : AI
4.WILDUN1840GKP+FEED,FOOD(I570)/RSPOMB β output : WILDUN
5.LOREM LS8515, WEN+ FEED, WATER (E570 - > output : > LS
6.LOREM IPSUM 8515 - > output : IPSUM
7.LOREM IPSUM-8515 - > output : IPSUM
8.LOREM IPSUM8515-> output : IPSUM
9.LOREM IPSUM8515 WATER2570 - > output : IPSUM
Please help me to get the corrcet output thank youu
Hope it helps,
Happy automation
Hi The DUMA and IPSUM is a random word,
and i want to catch the word before the number
thanks
Parvathy
(PS Parvathy)
August 18, 2023, 7:21am
4
Hi @StevenIsRobotOnline
Try this Regex Expression:
(?<=\d\.[A-Z\s]+?[A-Z\s]+?\-?)\d+|\d+(?=[A-Z])
Hope it helps!!
take the dynamic value which you get before or after the number you need to extract
pass into a variable then use this regex pattern in the place of IPSUM
Hi Thanks for the reply ,
but my question is
how to get the value of the word before the numbers ,
not to get the value of the numbers in this string
thank you for the advice anyway
StevenIsRobotOnline:
1.WILDUN DUMA 8515 β DUMA
2.WILWAL SE1865 GEN+ Feed, Food (N570) - > SE
3.WILWAL AI1865 GEN+ Feed, Food (N570) β AI
4.WILDUN1840GKP+FEED,FOOD(I570)/RSPOMB β WILDUN
5.LOREM LS8515, WEN+ FEED, WATER (E570 - > IPSUM β LS
6.LOREM IPSUM 8515 - > IPSUM
7.LOREM IPSUM-8515 - > IPSUM
8.LOREM IPSUM8515-> IPSUM
9.LOREM IPSUM8515 WATER2570 - >IPSUM
Hi @StevenIsRobotOnline ,
Maybe you could check with the Below Regex :
^.*?\s?([A-Za-z]+)\s?[-\d]+
Expression :
Regex.Match(strVar,"^.*?\s?([A-Za-z]+)\s?[-\d]+").Groups(1).ToString
Debu Panel :
Anil_G
(Anil Gorthi)
August 18, 2023, 7:25am
8
@StevenIsRobotOnline
First use this regex to get the valueβ¦the first matched value is what you need so use as below and then you can replace all special characters and spaces
[A-Z]*[ \-,]*(?=\d{4})
System.Text.regularExpressions.Regex.Replace(System.Text.regularExpressions.Regex.Match(str,"[A-Z]*[ \-,]*(?=\d{4})").Value,"[^A-Z]","")
[^A-Z]
- this takes care of removing extra characters
Hope this helps
cheers
1 Like
Anil_G
(Anil Gorthi)
August 18, 2023, 7:36am
11
Anil_G:
System.Text.regularExpressions.Regex.Replace(System.Text.regularExpressions.Regex.Match(str,β[A-Z][ -,] (?=\d{4})β).Value,β[^A-Z]β,ββ)
use this in assign activityβ¦here str is a string variable containing each string eg: WILDUN DUMA 8515
and the output of this world be the required string
Hope this helps
cheers
1 Like
system
(system)
Closed
August 21, 2023, 7:37am
12
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.