How to extract value from text file

Hi,

I’m attaching a sample txt file ,first it has to read that text file and then,
Sample1.txt (35 Bytes)
i need to extract the 4589 and store that in to a variable, after that in a loop it has to display ADD/SUB/MULTIPLY separately in message box and has to store in to a variable.
Can anyone please help me to solve this.

Hi @Chippy_Kolot

Try this

(?<=Invoice\s+\:\s+)\d+

Regards

hey @Chippy_Kolot
try this:
System.Text.RegularExpressions.Regex.Match(fileContent, "Invoice : (\d+)").Groups(1).Value

need to display
ADD
SUB
MULTIPLY,in loop using seperate message box.

@Chippy_Kolot

System.Text.RegularExpressions.Regex.Match(Input,(?<=Invoice.*\s+)\d+).Value

Hi @Chippy_Kolot

You can use the regular expressions to extract the required output,

- Assign -> Output = System.Text.RegularExpression.Regex.Match(Input,"(?<=Invoice :\s*)\d+").Value

image

Use the below regex for ADD/SUB/MULTIPLY

(?<=\/)[A-Z]+|[A-Z]+(?=\/)

image

you can use the above regex in Find Matching Patterns activity and the output is in Collection of matches, you can use for each to iterate the each item in the collection.

Hope it helps!!

Hi @Chippy_Kolot

To extract Add/SUB?MULTIPLY use below regex:

Assign-> Input= "Invoice : 4589
 
ADD/SUB/MULTIPLY"

Assign-> Output= System.Text.RegularExpressions.Regex.Match(Input,"(?<=\d+\s*)[A-Z/]+").Value.Trim()

Assign-> InvoiceNumber= System.Text.RegularExpressions.Regex.Match(Input,"(?<=Invoice\s+\:\s+)\d+").Value.Trim()


Regards

Hi @Chippy_Kolot

Check out this

Regards

@Chippy_Kolot

In message box:String.Join(Environment.NewLine, inputString.Substring(inputString.IndexOf(":") + 1).Split({"/"}, StringSplitOptions.RemoveEmptyEntries))
Str_Number=System.Text.RegularExpressions.Regex.Match(Input,"(?<=Invoice.*\s+)\d+").Value

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.