func getRightMostMatchingString(regex *regexp.Regexp, value string) string {
	loc := regex.FindStringIndex(value)
	if len(loc) == 0 {
		return ""
	}
	value = value[loc[0]:]
	if value[0] == ',' && len(value) > 1 {
		value = value[1:]
	}
	rightMostMatchingString := getRightMostMatchingString(regex, value)
	if rightMostMatchingString != "" {
		return rightMostMatchingString
	}
	return value
}
getRightMostMatchingString will return right must matching string
which satisfies given pattern
Example:
- Fetch last pattern matching on string
Pattern: {,.*:\[.*} string: "key1,key2,key3:[v1, v2, v3]"
Return value: key3:[v1, v2, v3]
package provisioner
import (
	"regexp"
	"strings"
	corev1 "k8s.io/api/core/v1"
)
func getNodeAffinityRules() NodeAffinity {
	var nodeAffinity NodeAffinity
	affinityValue := getNfsServerNodeAffinity()
	if affinityValue == "" {
		return nodeAffinity
	}
	rules := strings.Split(affinityValue, "],")
	for _, rule := range rules {
		nodeAffinity.MatchExpressions = append(nodeAffinity.MatchExpressions, getOneOrMoreNodeSelectorRequirements(rule)...)
	}
	return nodeAffinity
}
func getOneOrMoreNodeSelectorRequirements(
	requirementsAsValue string) []corev1.NodeSelectorRequirement {
	var nodeRequirements []corev1.NodeSelectorRequirement
	var complexReq corev1.NodeSelectorRequirement
	isComplexRequirement := regexp.MustCompile(`.*,+.*:\[.*`).FindString(requirementsAsValue) != ""
	if isComplexRequirement {
		matchingString := getRightMostMatchingString(regexp.MustCompile(`,.*:\[.*`), requirementsAsValue)
		if matchingString != "" {
			matchingIndex := strings.LastIndex(requirementsAsValue, matchingString)
			complexReq = getNodeSelectorRequirement(requirementsAsValue[matchingIndex:])
			requirementsAsValue = requirementsAsValue[:matchingIndex]
		}
	}
	if strings.ContainsRune(requirementsAsValue, rune('[')) {
		nodeRequirements = append(nodeRequirements, getNodeSelectorRequirement(requirementsAsValue))
	} else {
		for _, req := range strings.Split(requirementsAsValue, ",") {
			if strings.TrimSpace(req) != "" {
				nodeRequirements = append(nodeRequirements, getNodeSelectorRequirement(req))
			}
		}
		if isComplexRequirement {
			nodeRequirements = append(nodeRequirements, complexReq)
		}
	}
	return nodeRequirements
}
func getNodeSelectorRequirement(reqAsValue string) corev1.NodeSelectorRequirement {
	var nsRequirement corev1.NodeSelectorRequirement
	keyValues := strings.Split(reqAsValue, ":")
	nsRequirement.Key = strings.TrimSpace(keyValues[0])
	nsRequirement.Operator = corev1.NodeSelectorOpExists
	if len(keyValues) > 1 {
		valueList := strings.Split(
			strings.TrimSpace(
				strings.TrimLeft(
					strings.TrimRight(keyValues[1], "]"),
					"["),
			),
			",")
		if len(valueList) > 1 || (len(valueList) == 1 && strings.TrimSpace(valueList[0]) != "") {
			nsRequirement.Operator = corev1.NodeSelectorOpIn
			nsRequirement.Values = valueList
		}
	}
	return nsRequirement
}