Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^2: Perl Regex to take the UC Words.

by Anonymous Monk
on Mar 28, 2013 at 04:42 UTC ( #1025850=note: print w/ replies, xml ) Need Help??


in reply to Re: Perl Regex to take the UC Words.
in thread Perl Regex to take the UC Words.

Thx. Vinoth. That was very kind of you. but If there is digits we want to take, how we can do that... means "BROUGHTON VETERINARY GROUP123. Leicestershire456 mixed practice789 seeks experienced000 vet to replace assistant relocating to Scotland" and I want to take "BROUGHTON VETERINARY GROUP123" out of that.


Comment on Re^2: Perl Regex to take the UC Words.
Replies are listed 'Best First'.
Re^3: Perl Regex to take the UC Words.
by vinoth.ree (Prior) on Mar 28, 2013 at 04:52 UTC

    Try this way,

    use strict; use warnings; use Data::Dumper; while(<DATA>) { my @array = $_ =~ m/\b([A-Z]+(?:\d+)?)\b/g; print "@array\n"; } __DATA__ BROUGHTON VETERINARY GROUP123. Leicestershire mixed practice seeks exp +erienced vet to replace assistant relocating to Scotland GIRLING AND BOWDITCH VETERINARY SURGEONS We are looking for an experie +nced vet for our 5 vet mixed practice. STANHOPE PARK VETERINARY HOSPITAL. Due to a pregnancy epidemic we are +looking for 2 new vets, 100% small animal hospital in County Durham.

    All is well

      What about capitalized words later in the line? Shall they be excluded?

      use strict; use warnings; while(<DATA>) { my @array = $_ =~ m/\b([a-zA-Z]+[0-9]*)\b/g; foreach (@array) { last if /[a-z]/; print "$_ "; } print "\n"; } __DATA__ BROUGHTON VETERINARY GROUP123. Leicestershire mixed practice seek EXPE +RIENCED vet to replace assistant relocating to Scotland GIRLING AND BOWDITCH VETERINARY SURGEONS We are looking for an experie +nced vet for our 5 vet mixed practice. STANHOPE PARK VETERINARY HOSPITAL. Due to a pregnancy epidemic we are +looking for 2 new vets, 100% small animal hospital in County Durham.
      Thx. Vinoth

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (12)
As of 2015-07-28 16:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (258 votes), past polls