Parsing a string with [3:0] substring in itJAVA

Программисты JAVA общаются здесь
Anonymous
Parsing a string with [3:0] substring in it

Сообщение Anonymous »

I want to store two numbers from a string into two distinct variables - for example, var1 = 3 and var2 = 0 from "[3:0]". I have the following code snippet:

Код: Выделить всё

String myStr = "[3:0]";
if (myStr.trim().matches("\\[(\\d+)\\]")) {
// Do something.
// If it enter the here, here I want to store 3 and 0 in different variables or an array
}
Is it possible doing this with split and regular expressions?

Подробнее здесь: https://stackoverflow.com/questions/328 ... ring-in-it

Вернуться в «JAVA»