regex - Perl: Extracting multiple numbers from string -


could me in correcting me following code. want extract 2 numbers input string.

  input string [7:0] xxxx 

i want '7' , '0' loaded 2 variables (min , max). trying achieve

my ($max, $min); ($max, $min) = $_ =~ /[(\d+):(\d+)]/; print "min: $min max $max\n"; 

i getting result

use of uninitialized value in concatenation (.) or string @ constraints.pl line 16, <ph> line 165. min:  max: 1 

regards

[ , ] regex meta characters, have escape them

($max, $min) = $_ =~ /\[(\d+):(\d+)\]/; 

the brackets used denote character class: [ ... ] matches characters inside it, e.g. [abc] matches a.


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -