Indexof Position Notepad

Hello

I have a notepad. In that notepad I need to capture an information “ABCD” 012345. The problem is that this information changes its location every day. Day A is on line 300. Day B is on line 400. Day C is on line 350. I have extracted that information “012345” with static line location. How can I capture the location of the “ABCD” field. I need the get the value “012345”.

I have variable.split(Environment.Newline.ToCharArray(index position )

You could use regular expressions to extract the value. For example:

theValue = System.Text.RegularExpressions.Regex.Match(variable, "(?<=ABCD: )\d+").Value

If you provide us with a sample text we could help you to create a pattern to match the value you want.

1 Like

Hi.

This is the sample text.

Actually . Its works as : variable.split(Environment.Newline.ToCharArray(350 ), but i know the Monday will not work, because the ABCD field will not be at location 350.

imagen

It would be of great help, to be able to obtain the location of the ABCDE field. That is, either 300,350, or 400.

or get another way to get the 01234 data

Then use this pattern instead:

(?<=ABCDE +)\d+

With regular expressions, you don’t need to care about which line the information is located on. It will find the information as long as the pattern matches.

1 Like

Can your share your code?. I dont know how your make it that. =).

Just use an Assign activity like below:

matchedValue = System.Text.RegularExpressions.Regex.Match(inputText, "(?<=ABCDE +)\d+").Value

You need to change ABCDE to your field name of course. inputText is a string with the text from Notepad and matchedValue is a string variable that will contain the information you are looking for.

1 Like

Hi @Julian_Yamid_Torres_Torre

@ptrobot has done a great job of explaining and getting the result into a string variable :smiley:

If you want to learn about Regex - check out my Regex Megapost :blush:

3 Likes

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