Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > searching lines case-insensitive

Reply
Thread Tools

searching lines case-insensitive

 
 
James Hunt
Guest
Posts: n/a
 
      06-04-2004
Is there a way to do a case-insensitive search? This is what I have so far
....
I know that what I currently have is case-sensitive.
if($paramAction eq "SEARCH") {
open(SEARCH,"$csvfile");
@lines = <SEARCH>;
close(SEARCH);

foreach $line_entry (@lines) {
if($line_entry =~ /$searchkey/) {
print "$line_entry <br>\n";
}
}
}

James













 
Reply With Quote
 
 
 
 
Gunnar Hjalmarsson
Guest
Posts: n/a
 
      06-04-2004
James Hunt wrote:
> Is there a way to do a case-insensitive search?


You seem to be talking about a case-insensitive pattern match, and if
so, the answer is yes.

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

 
Reply With Quote
 
 
 
 
Jürgen Exner
Guest
Posts: n/a
 
      06-04-2004
James Hunt wrote:
> Is there a way to do a case-insensitive search?


Please define "search"? Exact match of whole line? RE? Text::Approx? ...

> This is what I have
> so far ...

[...]
> if($line_entry =~ /$searchkey/) {


Ah, REs. Did you check the fine manual?
The very first modifier that is mentioned in "perldoc perlre" talks about
Do case-insensitive pattern matching.

Jue


 
Reply With Quote
 
raymond
Guest
Posts: n/a
 
      06-05-2004
$line_entry =~ /$searchkey/i

this do search for case-insensitive

more deatils about perl regular expression try "perldoc
perlrequick,"perldoc perlre" "perldoc -t perlretut"

Raymond Raj X



"James Hunt" <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>...
> Is there a way to do a case-insensitive search? This is what I have so far
> ...
> I know that what I currently have is case-sensitive.
> if($paramAction eq "SEARCH") {
> open(SEARCH,"$csvfile");
> @lines = <SEARCH>;
> close(SEARCH);
>
> foreach $line_entry (@lines) {
> if($line_entry =~ /$searchkey/) {
> print "$line_entry <br>\n";
> }
> }
> }
>
> James

 
Reply With Quote
 
James Hunt
Guest
Posts: n/a
 
      06-05-2004
[snip]
> Ah, REs. Did you check the fine manual?
> The very first modifier that is mentioned in "perldoc perlre" talks about
> Do case-insensitive pattern matching.
>
> Jue




Perfect that's exactly what I needed.

--
JAMES HUNT


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Searching all instances of a pattern across multi-lines laredotornado Perl Misc 3 12-16-2009 08:29 PM
Google search result to be URL-limited when searching site, but notwhen searching Web stumblng.tumblr Javascript 1 02-04-2008 09:01 AM
Asp.Net Calender, how to display 5 lines if there are only 5 lines in one month? Jack ASP .Net 9 10-12-2005 03:44 AM
Modems, Analog Lines and ... Electrical Lines? Sens Fan Happy In Ohio Computer Support 5 09-02-2004 04:15 AM
Re: how to read 10 lines from a 200 lines file and write to a new file?? Joe Wright C Programming 0 07-27-2003 08:50 PM



Advertisments