http://qs321.pair.com?node_id=1181015

Nansh has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: Regarding pattern Matching
by Corion (Patriarch) on Feb 03, 2017 at 20:06 UTC

    Why should the output be AUDI and McLAREN when the input is Audi and McLaren?

    Why should FORD be removed from the list?

    Also, you can help us to provide better answers by showing us the code you have already written for this task. Please also tell us what it does and where it fails to do what you need.

Re: Regarding pattern Matching
by LanX (Saint) on Feb 03, 2017 at 20:43 UTC
    Looks like lc and hash should be sufficient.

    %hash=( audi => AUDI, ...); print $hash{ lc($input) };

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Je suis Charlie!

Re: Regarding pattern Matching
by ww (Archbishop) on Feb 03, 2017 at 21:10 UTC

    Please see Re: Pattern matching, a reply to your annonymous repeat of this question, for suggestions on improving your questions.


    Spirit of the Monastery

    Yet another gimmé request!
    Sorry, we expect SOPW to seek wisdom, not to ask us to do so for them.

Re: Regarding pattern Matching
by kcott (Archbishop) on Feb 04, 2017 at 13:39 UTC

    G'day Nansh,

    Welcome to the Monastery.

    As already pointed out by others, this is a poorly presented question. Without knowing what regex you've used, or what output your current code produces, it's impossible to say, with any certainty, why you're not getting the output you want. Please read "How do I post a question effectively?" before posting again.

    As a complete guess, given you need parentheses to capture text that, itself, includes parentheses, you may not have escaped parentheses correctly (see perlre):

    $ perl -E 'say +("X(a,b,c)" =~ /X(\([^)]+\))/)[0]' (a,b,c)

    Also consider stepping through your matching code with Regexp::Debugger.

    — Ken

Re: Regarding pattern Matching
by Anonymous Monk on Feb 03, 2017 at 19:58 UTC
    Hi my solution is like this: loop thru sorted array if value is found as key in hash then print. KTHANXBAI