Extraction of particular portion from notepad

Hi, Anyone can help me into this. I like to do extraction of notepad activity for a certain part of text . I Just split each and every line to get the specific text of line using spilt(" ",Environment.newline).After that i need to extract the particular line using index.

This text will be blurred

Hello @smarthari1997 ,

It would be better if you can share the content which you want to split and extract.
Then we can either use Regex expression or Split function to achieve this.

1 Like

As a new user i cant share here the file.
Here i exactly i need to extract data from 8to12 line alone.

Order Purchase Order Invoice Customer Output

                            Invoice History
  1. Inv: Invoice: Disc %: PTO Flg:
    S/O: Ord: Due: Ship:
    P/O: Req: BOL:
    Pro#: Via: Trl3: Amt:
    Sold: Trl1: Trl2:
  2. Ship: Amt: Amt:
    Addr:
    Grand: By: Vrfy:
    Item Number Site Disc % Price

Does that mean you just want to extract lines from 8 to 12?

For example in you file there are 20 lines of data and you just need to fetch lines between 8 to 12.

Is that correct? Also will the format be same for all the document?

yes from 8 to 12 i need to extract the data and copy to another notepad.
Its for only one document not for a bunch of files

Ok…So will that 8th line start with Inv and 12th line end with Price always?

Yes rahul exactly

Plz do as below.

image

System.Text.RegularExpressions.Regex.Match(Mytext,"(?<=Inv:)[\s\S]*?(?=Price)").Value

Mytext is the variable that you get if you read the file and you can use the above Regext to get only the required value.

1 Like

@smarthari1997 8 to 12 mean. is it from Inv to Trl2(ref Sold) or Inv to Price(last line)

1 Like

Ya rahul its working. And can we able do it in index format in notepad. If possible can you give me a hint

1 Like

yes usha- its Inv to Price

Hello,

If you want to get it by index you can use split as below.

String var=Split(YOUR TEXT,“price”)(0)
String var1=Split(var,“Inv:”)(1)

In the first split it will split the entire string based on the tag,“Price” (Make sure only one “price” is there in the entire text, else you can choose another string)…and you will get the string before to price. Then you can split with “Inv:” and we are getting the data after that string.

2 Likes

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