Hi team,
I need Regex value of below strings
String1=29 Choice1
String2=30 Choice 2
String3=31 Choice3
I need output as
For String1 as Choice1
For String2 as Choice2
For String3 as Choice3
anyone please help me on these regex
Please send the regex syntax for these values
Thank you in advance.
vrdabberu
(Varunraj Dabberu)
2
Hi @Mada_Sai_Krishna
You can use the below regex:
(?<=\d+\s+)[A-Za-z]+\s?\d+
Regards
pikorpa
(Piotr Kołakowski)
3
Hey @Mada_Sai_Krishna
try this:
System.Text.RegularExpressions.Regex.Match(inputString, "\bChoice\s*\d*").Value.Replace(" ", "")
rlgandu
(Rajyalakshmi Gandu)
4
@Mada_Sai_Krishna
StrOut=System.Text.RegularExpressions.Regex.Match(inputString,(?<=\d+\s+)[A-Z]+[a-z]+\s*\d+).Value
vrdabberu
(Varunraj Dabberu)
5
Hi @Mada_Sai_Krishna
use below syntaxes in Assign
Assign-> String1= "29 Choice1"
Assign-> String1Output= System.Text.RegularExpressions.Regex.Match(String1,"(?<=\d+\s+)[A-Za-z]+\s?\d+").Value.Trim.Replace(" ","")
Assign-> String2= "30 Choice 2"
Assign->String2Output= System.Text.RegularExpressions.Regex.Match(String2,"(?<=\d+\s+)[A-Za-z]+\s?\d+").Value.Trim.Replace(" ","")
Assign-> String3= "31 Choice3"
Assign-> String3Output= System.Text.RegularExpressions.Regex.Match(String3,"(?<=\d+\s+)[A-Za-z]+\s?\d+").Value.Trim.Replace(" ","")
Message Box-> "String1: "+String1Output+vbCrLf+"String2: "+String2Output+vbCrLf+"String3: "+String3Output
Regards
1 Like
Anil_G
(Anil Gorthi)
6
@Mada_Sai_Krishna
I believe choice is constant then use
Requiredvalue = System.Text.RegularExpressions.Regex.Match(StringVariable,"Choice\d+").Value
Or you can use split
Requiredstring = str.Trim.Split(" "c).Last
Cheers