3-5-13d1100+regex+to+match+an+exact+number+of+something

To make a regex to match an exact number of something (e.g. a group or a character) you can use negative lookahead and negative lookbehind.

For example, if you want to match only one hyphen and only one hyphen in the following string, then you can use this regular expression "(?<!-)-(?!-)" to exclude a hyphen occurring before it and a hyphen occurring after it.

-item1 --item2 --item3 -item1