Delete text before or after a specific text in a code

Could you help me with a code that would allow me to delete text before or after a specific text in a code?

Provide an example.

To reduce a text string, you might use these blocks (to begin with):

image

thx