Reputation: 3570
I have multiple <li>
in my code, well over 3,000 of them (don't ask!).
They are all either in the format:
<li>Name, Job, Company</li>
or
<li>Job, Company</li>
I need to find the ones that contain a Name
(i.e. the ones with two commas ,
, as opposed to just one), and remove the names. I was hoping to use Sublime Text's Regex find+replace feature.
Now, I can select all the lines that contain two commas using the following regex:
<li>.*,.*,.*</li>
But how do I now replace those with just the second and third .*
s, discarding the first?
Upvotes: 0
Views: 48
Reputation: 7376
sed -r 's/[^,]*,([^,]*,[^,]*)/\1/g'
not .*
because it would match the comma.
Upvotes: 1
Reputation: 11116
find this :
<li>.*,(.*),(.*)</li>
replace with :
<li>\1,\2</li>
or
<li>$1,$2</li>
whatever your editor supports
Upvotes: 2