Background
We define the two types of chain to be a string that contains only dashes, "-", or only underscores, "_". We link two chains using one equals sign, "=".
Criteria:
- The type of chain must change following an equals sign.
- You must link the chains, you can do so multiple times, and it does not matter what length the chains are so long as they are equal to or above one.
- The chain must not start or end with an equals sign.
- No two equals signs may be adjacent.
- There must be at least three characters, and both types of chain must show up.
- The chain must only contain underscores, dashes, and equals signs.
Your Task
Given a string, return True if it is a valid two-parallel-linked-chains (tplc) and return False otherwise.
Input: The string will be maximum 256 characters long. It may contain characters which are not underscores, dashes, or equals signs.
Output: Return either True or False, depending of if it is valid tplc or not.
Explained Examples
Input => Output
______=-------=___=-----=_=- => True
The string is a valid tplc because it follows all criteria.
Input => Output
=> False
Empty string does not satisfy criteria 5.
Input => Output
=_=- => False
The string starts with an equals sign, and does not satisfy criteria 3.
Input => Output
___ => False
There is only one type of chain, so the string does not satisfy criteria 5.
Input => Output
__==--- => False
There are two consecutive adjacent equals signs, so the string does not satisfy criteria 4.
Input => Output
_=- => True
The string satisfies all criteria.
Input => Output
_=----=___=--@- => False
The string contains a forbidden character, @, so the string does not satisfy criteria 6.
Input => Output
__=__ => False
The type of chain does not change after an equals sign, so does not satisfy criteria 1.
Input => Output
___--- => False
The chains are not linked (no equals sign), and does not satisfy criteria 2.
Test Cases
Input ~> Output
~> False
_ ~> False
_- ~> False
== ~> False
==_ ~> False
-_- ~> False
_== ~> False
=_=- ~> False
____ ~> False
-=__£ ~> False
*=___ ~> False
->-=_ ~> False
__=]- ~> False
0x=+y ~> False
--X__ ~> False
_==-- ~> False
-=_=_ ~> False
_-==_- ~> False
_-_-_= ~> False
_==__= ~> False
_=--__ ~> False
___=__ ~> False
--=__ _ ~> False
__=___=___ ~> False
______=----&---- ~> False
___=---------=________-_____ ~> False
--------=_________=-=_=-=_=----=__==----- ~> False
-=_ ~> True
_=- ~> True
-=__=--- ~> True
_=--=___ ~> True
_=-=_=-=_ ~> True
__=------ ~> True
__=------------=____________=--------------=_____________=-------- ~> True
---------=____________=----------=_=-=_=---------------=_______________________ ~> True
This is code-golf, so shortest answer wins.
-=_=_
(contains both types of chain but they do not alternate correctly). \$\endgroup\$-=_?
or-A__
orxx=yy
or others. \$\endgroup\$