-1

I have a piece of regex code that looks like this:

- class: pipe.steps.validate.Validate(.*?)id: validate

It works fine for everything between '- class: pipe.steps.validate.Validate' and 'id: validate'. The thing is, I want to include '- class: pipe.steps.validate.Validate' and 'id: validate' as well as all text in between. I tried to get the start (^) and end ($) of the line, but I couldn't figure out how to do it. Basically, I want the '- class: pipe.steps.validate.Validate' and 'id: validate' to be all green. How can I do that? Thanks.

enter image description here

enter image description here

ASH
  • 15,523
  • 6
  • 50
  • 116
  • 1
    Your regex already does it. It is working well. Depending on where you are using the regex, it might be already sufficient to use it as is. Where is it not working? What is the problem? – Wiktor Stribiżew Nov 20 '18 at 17:41
  • 1
    Again, your regex works. There is no point - in the majority of cases, and you have not specified any in the question - to wrap the whole pattern with a capturing group. There is no point in a group at all here. Remove `(` and `)`. What the regex101 highlights is captured substrings. That does not mean you will only get what is highlighted in the actual code. – Wiktor Stribiżew Nov 20 '18 at 18:36

1 Answers1

0

If you want to include the whole match, you have to change the positions of the parantheses:

(- class: pipe.steps.validate.Validate.*?id: validate)
Sven Hohenstein
  • 75,536
  • 15
  • 130
  • 155