in reply to Re^3: 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

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.

Replies are listed 'Best First'.
Re^5: regex to return line with name but not if it has a number
by Anonymous Monk on Apr 03, 2017 at 17:35 UTC

    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

        In my case my names are FistName LastName so your names above are correct but they would be first name last name combinations like: - Pat O'Reilly - Tony Smith - Jane de Figuera