I am writing a sample application in which I've came across the following problem:
I have to check to characters in terms of their "compatibility".
boolean checkIfPairCorrect(Character c1, Character c2) {...}
In a nutshell it is sth like: "Check if these characters make correct open-close pair". For example:
Pair "(" and ")" returns TRUE
Pair "{" and "}" returns TRUE
Pair "(" and "}" returns FALSE // incompatibile brackets
Pair ")" and "(" returns FALSE // wrong order
Pair "a" and "3" returns FALSE // 'a' or '3' are not the characters for which "closing" char can be found
You would say: "Simply write a regexp man!!!" using some Internet help like:
Regular Expression to match outer brackets
Regex to restrict only one occurrence of open and close brackets using C#
Regexp and brackets article
And you would be right, but... The problem is difficult for me because function can take some exotic characters as parameters (UTF-8 encoding) like japanese, turkish, arabic etc. I do not know what characters can be treated as open-close pair in other languages(cultures), so I am looking for a library which can deal with my problem.
Question: Do you know any library which could be helpful in my case, or do you have any tips how to deal with it?