Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Extract names

by Anonymous Monk
on Feb 18, 2013 at 14:32 UTC ( #1019346=perlquestion: print w/replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I would like to know how to extract names from a regex using notepad++?

Replies are listed 'Best First'.
Re: Extract names
by ww (Archbishop) on Feb 18, 2013 at 15:20 UTC
    We probably need more info to help.
    1. How do you define "names"?
    2. When you say "from a regex" do you mean the names are in a regular expression like  /sue mike fred rover/ or did you intend to ask how to extract names using a regex?
    3. What does your editor have to do with the question?

    Despite the danger in making assumptions, on a guess that you mean how does one extract names from a text document which contains names and other words, you may find some benefit from the following:

    a. Create an array with the names you want to extract (perl can do most anything, but washing windows and differentiating between names and other words are out of scope. See Tutorials)

    b. Slurp or read line-by-line (depending on the size of the document) the text file. open and, again, the tuts here.

    c. Test (see perlre, perlretut, et al_, word-by-word (for values of word meaning preceded or followed by a space, punctuation or EOL) in the line or file for matching against any of your array elements (names).
      If reading line-by-line, rinse and repeat.

    d. Capture the words that match names (see Tuts, the regex docs, etc) -- probably to an array with something like push @names_found, $name.

    e. Do something with the array.

    And, in deference to the values of the Monastery and those from whom you ask help, you might wish to read some of the documents that lay out what are considered "good practices" here at PerlMonks I know what I mean. Why don't you?, On asking for help and How do I post a question effectively?.

    If you didn't program your executable by toggling in binary, it wasn't really programming!

Re: Extract names
by karlgoethebier (Monsignor) on Feb 18, 2013 at 22:15 UTC
Re: Extract names
by Anonymous Monk on Feb 18, 2013 at 23:48 UTC
    Personally I would whack the regex upside the head with notepad++. That usually extracts a few names that, like this post, I should not write here.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1019346]
Approved by NetWallah
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (11)
As of 2018-06-22 15:40 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (124 votes). Check out past polls.