Skip to content
Advertisement

Use grep to match a pattern in a line only once

I have this:

JavaScript

Which gives this:

JavaScript

I understand whats happening. How do I stop grep from trying to continue matching after 1 successful match?

How do I get only

JavaScript

Advertisement

Answer

You need to do the grouping: (...) followed by the exact number of occurrence: {<n>} to do the job:

JavaScript

Hope it helps. Cheers!!

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement