1

for example I have<img className='class' src='somelink' /> and I want to grab just className='class' I already tried / className='.+'[ |>] Im traversing files looking for all classNames but this img example gives me everything including the src='...' what would be a good expression to give me all classNames and only the classNames with any possibilities inside the quotes?

Gavyn
  • 99
  • 7

1 Answers1

1

You should use className='.+?'. This will make the expression "lazy" instead of "greedy". Basically, greedy means that the expression will find everything up to the last ' in the whole string while lazy means it will stop as soon as it finds the first '.

This is probably a better explanation.

DonovanM
  • 1,174
  • 1
  • 12
  • 17