Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Regarding pattern Matching

by Nansh (Acolyte)
on Feb 03, 2017 at 19:54 UTC ( #1181015=perlquestion: print w/replies, xml ) Need Help??

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 (Pope) 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 (Sage) 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 (Bishop) 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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1181015]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2021-12-05 06:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    R or B?



    Results (31 votes). Check out past polls.

    Notices?