Forum: Ruby on Rails ruby regular expression issue matching

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Chris H. (Guest)
on 2009-01-28 03:12
(Received via mailing list)
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?
Philip H. (Guest)
on 2009-01-28 03:16
(Received via mailing list)
> 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 '$'.
Chris H. (Guest)
on 2009-01-28 03:20
(Received via mailing list)
doh.  I do that in the rest of the expression, duh..   Thanks.  Mind
fart I guess.
This topic is locked and can not be replied to.