I have an expression if $index =~ 3|7|11|15|19, and I only want to match those numbers. Only, the number "13" is being returned because the number 3 is part of the bunch to match. How do I tell it to only match on the first digit so that 13 isn't returned?
Announcement
Collapse
No announcement yet.
pattern match
Collapse
X
-
depends on what the string is.
/\b3\b/ will match only " 3 " or "3" or "3 " or " 3". \b is the word-boundary anchor.
/^3/ will match 3 at the beginning of the string, and anything after it.
/^3$/ will match only 3, with no spaces
hope this helps. if not, describe your problem more."There is more than one way to do it."
Comment