Regex removing anything that is not a 14-digit number followed with space
I'm trying to invert this expression: ([0-9]{14} ) , so all 14 digit numbers followed by a space. I looked everywhere, and it seems that the best way should be using negative lookahead . But when I try apply q(?!u) to my case >> (?!([0-9]{14} )) , it doesn't work. What am I doing wrong? I will appreaciate any advice, thank you. The point is to remove everything that is not a 14-digit chunk of text while preserving those 14-digit chunks. If you want to delete text other than 14 digits followed with a space, use (\b\d{14} )|. and replace with $1 . The pattern matches and captures (we can refer