根据java中的典型条件拆分字符串?

根据java中的典型条件拆分字符串?,java,regex,Java,Regex,我的输入字符串如下所示: String sample1 = "productName/@languageCode"; String sample1="brandNameInformation/languageSpecificBrandName/@languageCode"; 我只想在出现“/”时拆分它,而不想在“/@”时拆分它 我怎么做? 有人能帮忙吗?您可以使用: 输出: [productName/@languageCode] [brandNameInformation, languageS

我的输入字符串如下所示:

String sample1 = "productName/@languageCode";
String sample1="brandNameInformation/languageSpecificBrandName/@languageCode";
我只想在出现“/”时拆分它,而不想在“/@”时拆分它

我怎么做? 有人能帮忙吗?

您可以使用:

输出:

[productName/@languageCode]
[brandNameInformation, languageSpecificBrandName/@languageCode]

String[]parts=sample1.split(“/[^@]”)查看并搜索“向前看”。
[productName/@languageCode]
[brandNameInformation, languageSpecificBrandName/@languageCode]