Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

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

by Corion (Patriarch)
on Apr 03, 2017 at 13:50 UTC ( [id://1186824]=note: print w/replies, xml ) Need Help??


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

Thank you for clarifying your situation. To better understand it, can you please post some concrete (yet anonymized!) lines together with the indication of whether they should match or not?

If you give us the concrete input you have and the relevant code you have, we can much easier pinpoint where your approach goes wrong and provide relevant documentation and help.

From your description, I would think that you could simply reject all lines that match /^-.*\d.*\|/, but your original approach seems to be much longer.

Replies are listed 'Best First'.
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

    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.

      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]+$)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (5)
As of 2024-04-25 14:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found