मेरे पास यह स्ट्रिंग है जिसे मैं एक टेक्स्ट फ़ाइल से ले रहा हूं।उलझन में कैसे जावास्क्रिप्ट में काम करता है .split() जावा
"1 normal 1 [(o, 21) (o, 17) (t, 3)]"
मैं स्ट्रिंग सरणी में 1, normal, 1, o, 21, 17, t, 3
लेना चाहता हूं।
Scanner inFile = new Scanner(new File("input.txt");
String input = inFile.nextLine();
String[] tokens = input.split(" |\\(|\\)|\\[\\(|\\, |\\]| \\(");
for(int i =0 ; i<tokens.length; ++i)
{
System.out.println(tokens[i]);
}
आउटपुट:
1
normal
1
o
21
o
17
t
3
क्यों रिक्त स्थान सरणी में संग्रहीत किया जा रहा है।