-2

I want to find all the files which uses <Button> component with className props in Visual studio editor.

Tried this regex <Button.*className.*> . It works partially. It didn't match the new line case. Kindly, check attached screenshot.

Last line button component didn't match. Because, props entered in a new line. I tried \n. It didn't work..

https://regex101.com/r/y2lQUf/3/

enter image description here

Karuppiah RK
  • 3,894
  • 9
  • 40
  • 80

1 Answers1

0

Change .* to [^>]*. By default . matches everything except newline, so .* won't match across multiple lines.

<Button[^>]*className[^>]*>

DEMO

Barmar
  • 741,623
  • 53
  • 500
  • 612