I have not used perl regex before and am struggling to only extract the first occurrence from some html. The html concerned is as follows:
<tr><th class="a-span5 a-size-base">Model number</th><td class="a-span7 a-size-base">MK6174</td></tr><tr><th class="a-span5 a-size-base">Part Number</th><td class="a-span7 a-size-base">MK6174</td></tr>
I am trying to extract only the first match of MK6174.
The current regex I have come up with is
([A-Z0-9_.\/-]{6,})
(I have many other model numbers ranging from 6+ characters long, all being alphanumeric. (a few contain the special characters above)
From my research I understand I need to somehow use .*? or .+? to make it non-greedy, but I cannot find the correct place to put this?
I find if I put it at the end then it makes no difference, and anywhere inbetween it ends with 0 results.
I have also tried adding /g onto the end to see if that works and that yields zero results.
Also, I need to make it so this works all in one regex, as the program I am using to do this doesn't work when I enter one regex to filter out the model number html code (up to the closing td tag), then the above regex to pull the MK6174 out.
What could I do to fix this?
Edit: I forgot to mention that with my current regex, my output result is 'MK6174MK6174'