Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^3: regex to return line with name but not if it has a number

by Anonymous Monk
on Apr 03, 2017 at 13:57 UTC ( [id://1186828]=note: print w/replies, xml ) Need Help??


in reply to Re^2: regex to return line with name but not if it has a number
in thread regex to return line with name but not if it has a number

Here's an example of the data that I'm currently getting:

- Anne Green| Manufacturing Engineer at Emerson … · - 3,600+ Dental Lab Jobs in Burlingame, CA | ... Director (47) Exe +cutive (10) See more. ... Lab jobs in Burlingame, CA. - 85 Clinical Laboratory Scientist Jobs in Mountain View, CA ... › + Dental Scientist Jobs 85 Clinical Laboratory Scientist jobs in Mount +ain View, CA on LinkedIn. Leverage your professional network, ... Bur +lingame, California (4) Dublin, California (2) - 152 Laboratory Technician Jobs in South San Francisco, CA ... Jo +bs › Dental Technician Jobs LinkedIn has 152 Dental Technician jobs i +n South San Francisco, ... 1-2 years of previous academic or commerci +al lab experience a plus. ... Burlingame, CA, US. … - 130 Quality Control Director Jobs in Mountain View, CA ... Jobs +› Quality Control Director Jobs New Quality Control Director jobs add +ed daily. LinkedIn. Sign in; ... Burlingame, California (1) Company. +Relypsa (7) Aramark (3) Think Surgical (3) Cushman ...
I'd like have line one returned as it's a name but not the others. Thanks.

Replies are listed 'Best First'.
Re^4: regex to return line with name but not if it has a number
by 1nickt (Canon) on Apr 03, 2017 at 14:31 UTC

    Since you know your data format:

    use strict; use warnings; print $_ =~ s/\|.*//r for grep { /^\D/ } map { split /^-\s*/ } <DATA>; __DATA__ - Anne Green| Manufacturing Engineer at Emerson â&#128;¦ · - 3,600+ Dental Lab Jobs in Burlingame, CA | ... Director (47) +Executive (10) See more. ... Lab jobs in Burlingame, CA. - 85 Clinical Laboratory Scientist Jobs in Mountain View, CA ... + › Dental Scientist Jobs 85 Clinical Laboratory Scientist jobs in Mo +untain View, CA on LinkedIn. Leverage your professional network, ... +Burlingame, California (4) Dublin, California (2) - 152 Laboratory Technician Jobs in South San Francisco, CA ... + Jobs › Dental Technician Jobs LinkedIn has 152 Dental Technician job +s in South San Francisco, ... 1-2 years of previous academic or comme +rcial lab experience a plus. ... Burlingame, CA, US. â&#128;¦ - Jim Bob| Chief IP Arachnologist at Some Recruitment Firm, Inc. - 130 Quality Control Director Jobs in Mountain View, CA ... Jo +bs › Quality Control Director Jobs New Quality Control Director jobs +added daily. LinkedIn. Sign in; ... Burlingame, California (1) Compan +y. Relypsa (7) Aramark (3) Think Surgical (3) Cushman ...
    $ perl 1186828.pl Anne Green Jim Bob
    ( Note Perl 5.14 required for s///r )

    Hope this helps!


    The way forward always starts with a minimal test.

      Thanks this does help! Your example above and using the following regex tester has really helped: https://regex101.com. I do have one question for you or anyone as I've been doing a lot of reading and I think I've found a simpler way to do what I want. How can I match a hyphen followed by a name with a regex? I have the following code that doesn't match. If I add an or "|" between the statements I do match but I don't want an or, I want and and.

      (?:^-)(?=[A-Z]'?[-a-zA-Z]+$)

        What is "a name"?

        Would the following be names?

        d'Artagnan O'Reilly 't Hooft de Figuera van der Vaart

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (3)
As of 2024-04-25 09:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found