0

So I am trying to put some regex together that looks for 2 instances of a national insurance number. But it needs to find the NIN regardless of its placement so it doesn't matter if there are other words in between or on new lines.

((\W|^)([a-zA-Z]{2}(|\s|\W))([0-9]{2}(|\s|\W)){3}([a-zA-Z]{1})(.*)){2,}

This is as close as i've got however this only works when on the same line it doesn't work if the NIN is on a different line

Fomnus
  • 75
  • 1
  • 1
  • 7
  • 1
    `.` does not match line break chars by default. Use the workaround, `[\w\W]`, or the appropriate DOTALL modifier. – Wiktor Stribiżew Apr 29 '20 at 08:49
  • Why not parse the file line by line? – altabq Apr 29 '20 at 08:49
  • this doesn't seem to work, if there is text on the new line before the NIN it doesn't match, example: ND111111D jnjkjnkjn dfsdf ND111111D ND111111D jnjkjnkjn ffdsfds ND111111D doesn't throw a match – Fomnus Apr 29 '20 at 12:58

0 Answers0