I need only numbers, but i should get the numbers based on Error message, if the error message is " The code is not generated" then i should take the digits.
The text file will be having many Error messages, i should take digits only if the error message is (The code is not generated), is there a way? can u explain in detail
@Manikandasamy I guess if Error Message :The code is not generated. than Error For Record will have numeric keyword so in this case you can use this regex
Hi
if this is stored in a string variable named
str_input = “Error For Record 2 : 1234559remarks
Error Message :The code is generated.”
then the OUTPUT will be with a assign activity like this str_input = String.Join(“”, str_input.Split(Environment.NewLine.ToArray()))
followed by that another assign activity like this str_output = IF(str_input.ToString.Contains(“The code is not generated”),System.Text.RegularExpressions.Regex.Match(str_input.ToString,“\s[0-9]{2,}”).ToString.Trim,String.Empty)
The above suggested would give only one output buddy
and if we want for multiple occurence then use MATCHES activity where in the input string mention the variable str_input after this assign
then mention the Expression with a value as “(?<=Record).*(?=The code is generated)”
and get the output with a variable named out_matches
–now use a FOR EACH activity and pass the above variable out_matches as input and change the type argument as System.Text.RegularExpressions.Match and inside the loop use a WRITE LINE ACTIVITY like this System.Text.RegularExpressions.Regex.Match(item.ToString,“\s[0-9]{2,}”).ToString.Trim
where item is the variable from for each loop
this will display all such matching values
Use this Code and assign it to a string will give you the desired output:
System.Text.RegularExpressions.Regex.Match(tt,“(?<=:.)(\d+)(?=.)(.*\n)(?=Error Message :The code is not generated)”,System.Text.RegularExpressions.RegexOptions.Compiled).Groups(1).Value