The problem is your second regular expression. The second regular expression has .+, which is the greedy quantifier corresponding to each character. The first group will try to match as much as possible.
(6.0xxxx)(x)
In parentheses are two groups that will match your regular expression.
There are two ways to solve this problem. The first is to use a lazy quantifier instead of a greedy quantifier:
/(.+?)(x+$)/
+ , , .
(6.0)(xxxxx)
.
, , , x.
/(^[^x]+)(+x$)/
, ( , x). x 1, .