Ruby regular expression issue matching


#1

I have something like this to match:

//s-#{slot}/p-#{port}/sts-#{sts}/

The problem is the variable STS if it is a 1 matches on 1,10,11,12,13
and so on.

How do I get it to match only the value and nothing sles?


#2

I have something like this to match:

//s-#{slot}/p-#{port}/sts-#{sts}/

The problem is the variable STS if it is a 1 matches on 1,10,11,12,13
and so on.

How do I get it to match only the value and nothing sles?

What follows the sts portion in your string? Is it something like
“sts-123-foo” or “sts-123?foo” or something? You need to figure out
what that character is and then add it to the regular expression. Or
if it’s nothing and that’s the end of the line anchor it with ‘$’.


#3

doh. I do that in the rest of the expression, duh… Thanks. Mind
fart I guess.