in reply to A Quick Regex Question

To match a sequence of "p"'s, "e"'s, "r"'s and "l"'s, you can use a character class,

while (<>) { print if m/[perl]+/; }
You are capturing the last matched character with those parens. Is that what you mean to do? If you want to capture the whole string, the parens should contain the '+'.

After Compline,
Zaxo

Replies are listed 'Best First'.
Re^2: A Quick Regex Question
by Nkuvu (Priest) on Oct 09, 2006 at 21:46 UTC

    That was my first thought also, but I'm not positive that the original poster meant this.

    Instead of p or e or r or l, I thought that the requirement was p and e and r and l (in any order). So I would expect that "orange" wouldn't be a valid match, given that it doesn't contain 'p' and 'l'. The given character class does, of course, match "orange" just fine.