hyphen vs minus in regex

M

mm

In a regular expression,
is a hyphen simply -
whereas a minus sign is \-
I am trying to understand the code below:

$addend_two = (rand 200) - 100;

$addend_two =~ /(\-?[\d]+)\.?[\d]*/ ? $intPart2 = $1 : die "No
integral value\n" ;
 
D

dw

mm said:
In a regular expression,
is a hyphen simply -
whereas a minus sign is \-
I am trying to understand the code below:

$addend_two = (rand 200) - 100;

$addend_two =~ /(\-?[\d]+)\.?[\d]*/ ? $intPart2 = $1 : die "No
integral value\n" ;

a minus and a hyphen are both simply -
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top