Delete Text to a certain word

Hello everyone,

I have a query, there is some way to delete text within a string to a certain word, that is, I want to delete all the text to a certain word.

Thanks :slight_smile:

1 Like

Yah that’s possible
Can I have a example
Cheers @askPWC

Example:

Enterprise: Hello, S.A.
Date: xxxxxxx
------(more text)
Finiquito(is the word)(I wish to delete all of the above until this text)
Juan Perez (It’s the text I want to keep)(this is the last text in the string)

Thanks :slight_smile:

So you want this alone from the string

The last line alone
Right

Cheers @askPWC

That’s right
:slight_smile:

1 Like

If so we can try with this expression
Take like we have the string in a a string variable named
Str_input = “Enterprise: Hello, S.A.
Date: xxxxxxx
------(more text)
Finiquito(is the word)(I wish to delete all of the above until this text)
Juan Perez”

Then
The output be like this
Str_output = Str_input.Split(Environment.Newline.ToArray).Last.ToString

So the output is
Str_output = “Juan Perez”

Cheers @askPWC

@askPWC do you always ONLY want to keep the last row text? If so that’s much easier. Just split it by newline and only use the last string in the array.

Or is it possible that there is text below Juan Perez in your example? Also, do you want to keep Finiquito, or do you want to have that removed as well? If you want to remove Finiquito, then you should split the text using the delimiter “Finiquito”, then only use the 2nd string in the array (index = 1). If you want to keep Finiquito, then you’ll need to use Regex Split instead

1 Like

yes, I am checking the best one to extract a piece of information within a string, I already deleted all the text that is after the keyword, now I want to delete all the text from “Finiquito” to up :slight_smile:
Im trying Regex to :slight_smile:

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