in reply to look-ahead and look behind!!

The match string for a look behind match must match a fixed number of characters. That means that ?, *, + and {n, m} are not allowed because they can match a variable number of characters. It also means that if you use |, each clause must be the same length.

If you really, really must use a look behind to match the first a then you could:

$str =~ /(?<=^a)/;

but all you actually need is /a/.


Perl is environmentally friendly - it saves trees

Replies are listed 'Best First'.
Re^2: look-ahead and look behind!!
by narainhere (Monk) on Oct 22, 2007 at 10:29 UTC
    Hey monks I am not to be mis-understood over here as a person who wants to make his life complex.Actually I have some complex and confidential code that should not be posted.So I emulated the scenario with a simple yet to-the point code :)

    The world is so big for any individual to conquer

      I suspect you now have what you need. However if not then you need to give us a little more context.

      We don't mind irrelevant details being omitted from a problem description - indeed we encourage it, but make sure you leave enough detail to allow us to help solve your actual problem. To that end it often helps to tell us something of the larger problem so we can help you find the most appropriate solution.


      Perl is environmentally friendly - it saves trees