rajkk04 has asked for the wisdom of the Perl Monks concerning the following question:
Im trying to extract some words which is present between two double quotes " " Im able to extract but the issue is if any double quoted words is preceded by a word , it is also getting displayed For eg:- In the word :- "perl"monks i need the word Perl to be extracted but "perl"monks is getting displayed.
The snippet is given below:-
use strict; open FILE, "<searchfile.txt"; my @line = <FILE>; for (@line) { if ($_ =~ m{["](.*?)["]}) { print "$_\n"; } }
P.S:- I dont know whether the below scenario is possible but please give suggestions and ideas:-
When Im extracting a string for eg perl in the above scenario the total no of letters is 4
similarly i want to extract only 4 letters (alphanumeric) in the complete text. Thanks Monks!!!!!!!!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Extracting Strings - Special Cases
by choroba (Cardinal) on Jan 07, 2013 at 13:21 UTC | |
|
Re: Extracting Strings - Special Cases
by Athanasius (Archbishop) on Jan 07, 2013 at 13:35 UTC | |
|
Re: Extracting Strings - Special Cases
by ansh batra (Friar) on Jan 07, 2013 at 13:18 UTC | |
|
Re: Extracting Strings - Special Cases
by Anonymous Monk on Jan 07, 2013 at 19:59 UTC |