How can i get the String between "pattern" and end of line?

I’m trying to get the string between a certain word “pattern” and the end of that line, I tried using \r\n but it doesn’t work, when I export the code it appears as \\r\n somehow. The only workaround I have found is to use the first word of the following line as the 2nd string of the string between action, and use the split string action with end of line as the “splitter”, but then again, I would get an array, and I can’t seem to find a way to put the first value of that array on a string variable, and since i’m doing this with several texts I would had to use an array of arrays to store them so that I could easily use them later on, which doesn’t exist, plus, I have no guarantees that the first word of the next line is always the same.

What I really need is a way to go through these several texts, and append the word between “pattern” and the end of that line on an array. So that this array will be later on iterated and treated properly.

1 Like

Hi,
In my understanding, you are trying to extract string that appears after the word pattern and if it is the case in the array u can use substring between option which is available under Text to extract and store the result to a string variable. Attached below snapshot for reference.

Specify the text pattern in Extract text after dialogue.
And later u can convert the string to list/array by using Expression available under the variables tab
Hope it helps!!

2 Likes

Also, you can use this workaround suggested by @alexander.haiduk85 to save the new line symbol in a variable

and then use this variable in the Substring action

1 Like

Thanks, but I forgot mentioning im already using that activity, the problem is that I cant define end of line as the extract text before string

1 Like

I succesfully created the br String as a breaking line String, unfortunately, when using the substring between function, the output comes as null.
My work around was splitting using the word pattern, then assigning the value of the 2nd position of the resulting array to a String variable, then splitting that string using “Windows line break (CR+LF)”, and assigning the value of the first position to my desired string variable.

1 Like

I’m glad you made it work :slightly_smiling_face:

Although it is weird that using a variable didn’t work.
Maybe, I misunderstood your use case a bit…:thinking:

substring-end-line.zip (808 Bytes)

Your rpae worked, and after some minutes of modifying and trying I found out the problem occurs when the str1 value comes from clipboard, and not from read file action like the example you gave me, so I tried using linux/macOS line brake to create the br string and it worked fine.
Thanks for you help and availability.

1 Like

Yeah, right, when the clipboard is used, it separates lines with Linux/MacOS line brake, not Windows line break.