Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
文字列があります。カンマで分割する必要がありますが、前の文字が\の場合、この部分は分割しないでください。
たとえば、String str = "first,second\\,third,fourth"私は必要ですString[] strs = { "first", "second\\,third", "fourth" }
String str = "first,second\\,third,fourth"
String[] strs = { "first", "second\\,third", "fourth" }
このようなもの?
String str = "first,second\\,third,fourth"; String[] strs = s.split("(?<!\\\\),");
説明については、java.utils.regex.Patternのドキュメントを参照してください。