0

Hello i have a string Team and members but members are in [ ] and I need to replace [ and ] with , so I can split the long thingy. When I try to write liss.toString().replaceAll("[" , ","); i get this error : Exception in thread "AWT-EventQueue-0" java.util.regex.PatternSyntaxException: Unclosed character class near index 0 [

Anyone maybe knows how can I replace "[" and "]" with ","?

Cimb
  • 1
  • 2
    `replaceAll` expects a regex. just use the normal `replace` function. Both will replace all instances of fitting matches. Those 2 methods are just really badly named. – OH GOD SPIDERS Nov 17 '20 at 16:17
  • 2
    ... or use `"(\[|\])"`, though just using `replace` is arguably the better option for replacements that aren't complex – Zoe Nov 17 '20 at 16:20
  • For future questions, please format any code in your question and include a more complete example. For help on formatting check this out: https://meta.stackoverflow.com/questions/251361/how-do-i-format-my-code-blocks – Rob Elsner Nov 17 '20 at 16:24

0 Answers0