Java如何从数组中获取特定单词

Java如何从数组中获取特定单词,java,Java,我有一个数组 Array[0] = "Information of student, Class Allocated: 2B (13), Class Opposite: 1B (12)" Array[1] = "Information of student, Class Allocated: 1B (12), Class Opposite: 2B (13)" Array[2] = "Information of student, Class Allocated: 1A (10), Class O

我有一个数组

Array[0] = "Information of student, Class Allocated: 2B (13), Class Opposite: 1B (12)"
Array[1] = "Information of student, Class Allocated: 1B (12), Class Opposite: 2B (13)"
Array[2] = "Information of student, Class Allocated: 1A (10), Class Opposite: 2A (11)"
我需要已分配班级的信息:和相对班级的信息。我需要得到2B和13,但存储在不同的变量中。哪一种可能

For Array[0]
Floor = 2B
ClassNo = 13
Opposite = 1B
OppositeClass = 12

有人能告诉我怎么得到它吗?非常感谢您的帮助。

在字符串中使用拆分方法

假设您有标准格式

String [] commasplit = Array[0].split(",");
然后

String [] allocated = commasplit[1].split(" : ");
String allocatedValue = allocated[1] //2B (13)

给定代码,用方法参数编写一个通用方法,这样你就不会多次编写它。

你能说得更清楚吗?到目前为止你尝试过的任何东西吗?谷歌“java正则表达式”首先,为一行
数组定义你自己的数据模型,然后提供一个方法来解析模型中的一行,例如:@newtojava-按空格拆分:)也可以拆分2B和13吗?例如,字符串floor=2B;int room=13这应该通过模式匹配而不是简单的分割来完成