I'm trying to create a regex that blew my mind. How do I make the regex negation below when I have two consecutive numbers?
/^([\p{L}\p{N}\. ]+)(, ?| )([0-9-]+[a-z]?)(, ?| |$)(.*)/iu
Valid examples:
Text Text 123 anything
Text Text, 123, anything
Text Text 123B anything
Text Text, 123B, anything
Text 123 anything
Text 123B anything
Text, 123, anything
Text, 123B, anything
987 123 anything
987 123B anything
987, 123, anything
987, 123B, anything
(Need to be) Invalid examples:
Text Text 456 123 anything
Text Text, 456, 123, anything
Text Text 456 123B anything
Text Text, 456, 123B, anything
Text 456 123 anything
Text 456 123B anything
Text, 456, 123, anything
Text, 456, 123B, anything
987 456 123 anything
987 456 123B anything
987, 456, 123, anything
987, 456, 123B, anything
But as you guys can see, all the examples above are valid for my regex: https://regex101.com/r/6t5Oq5/4
Requirements: The first group may have letters or numbers. The second group can have numbers or numbers followed by a letter, and the third group can have anything. All groups can be separated by commas or space. And all letters and numbers can be any size. There can not be consecutive numbers in the string, unless the number is in the first group or in the last group (anything).
What is the best way to do this?