(?:~~)?1(?:~~)?2(?:~~)?
matches all your example strings. Is that what you meant?
Explanation:
(?:~~)
combines two tildes into a single (non-capturing) group.?
makes that group optional.
10
solved I need a pattern in regex engine to ignore a specific set of characters(eg: “~~”) [closed]