0

I have the following list:

find **data** find find
find **data** find find
find **data** find find
find **data** find find
found
find data find find
find data find find

I would like to match all **data** until the word "found". All data after found I would like to escape.

TylerH
  • 20,799
  • 66
  • 75
  • 101
DS9AGRI
  • 9
  • 1
  • 1
    are you using script/ programs or you want to active that from cli – Sudip Ghimire Dec 05 '20 at 01:42
  • 2
    In what programming language and what regex engine? – Ken White Dec 05 '20 at 01:54
  • 1
    Please use the [edit] feature to edit your original question, rather than posting additional details of the question as an answer. This is not an answer to the question. – Claies Dec 07 '20 at 08:17
  • Does this answer your question? [Regular expression to stop at first match](https://stackoverflow.com/questions/2503413/regular-expression-to-stop-at-first-match) – Claies Dec 07 '20 at 08:18
  • Please add the tag of the tool/language to your question. – Bohemian Nov 10 '21 at 20:35

1 Answers1

0

Use a look ahead to assert that found appears somewhere after the match:

(?s)\*\*data\*\*(?=.*found)

See live demo.

If your language/tool does not support the DOTALL flag (?s), use flag options (often m), eg

/\*\*data\*\*(?=.*found)/m
Bohemian
  • 412,405
  • 93
  • 575
  • 722