-1

I am trying to post a JSON request to my api endpoint but it is failing because of Chinese brackets which is present in my request. Currently, my request contains:

{"name":"聚思(杭州)自动化有限公司"}

When I am removing the Chinese brackets and replacing it with normal ( ) , I am able to post the request as below:

{"name":"聚思 (杭州) 自动化有限公司"}

Moreover, I can find that my api code is not able to understand any Chinese character symbols/punctuation, but can understand Chinese alphabets/letters. Currently, the regex expression I am using is this: ^[\w\s~/\@%#$!~^;`*&()_+=[]{}|\,\'.?:<>-]{1,100}$

May I know, how can I modify the above regex expression(or maybe the request before posting to API endpoint) so that my java code does not reject the Chinese symbols/punctuation? Any help is appreciated. Thanks!

1 Answers1

0

You can use hex unicode in a regex to specify non-standard characters:

\uFF08 is and \uFF09 is .

var str = "(example)";

str.replace(/\uFF08/g,"(").replace(/\uFF09/g,")");

// => (example)
DenverCoder1
  • 2,253
  • 1
  • 10
  • 23