Re: Perl regular exp

2006-04-12 Thread Randal L. Schwartz
> "Sonika" == Sonika Sachdeva <[EMAIL PROTECTED]> writes: >> You could instead keep in mind that: >> >> /^(?=.*foo)(?=.*bar)/ Ooops. that should be (?=.*?foo) for efficiency. >> my $regex = "^" . join "", map "(?=.*\Q$_\E)", @words; change .* to .*? there. -- Randal L. Schwartz - Stoneh

Re: Perl regular exp

2006-04-12 Thread Sonika Sachdeva
Thanks all. On 12 Apr 2006 06:23:53 -0700, Randal L. Schwartz wrote: > > > ""Ankur" == "Ankur Gupta" <[EMAIL PROTECTED]> writes: > > "Ankur> Sonika Sachdeva scribbled on > Tuesday, > "Ankur> April 11, 2006 4:27 PM: > > >> Actually I am looking for AND and OR combin

Re: Perl regular exp

2006-04-12 Thread Randal L. Schwartz
> ""Ankur" == "Ankur Gupta" <[EMAIL PROTECTED]> writes: "Ankur> Sonika Sachdeva scribbled on Tuesday, "Ankur> April 11, 2006 4:27 PM: >> Actually I am looking for AND and OR combinations..and the number of >> words are not fixed. >> ie @words is the variable and I

Re: Perl regular exp

2006-04-12 Thread Randal L. Schwartz
> ""Sonika" == "Sonika Sachdeva" <[EMAIL PROTECTED]> writes: "Sonika> Hi , "Sonika> print $line if ($line =~ /pattern1 && pattern2 && pattern3/); "Sonika> works .. but For what meaning of "works"? If you want to find the string "pattern1 && pattern2 && pattern3", I guess. That's been prett

Re: Perl regular exp

2006-04-11 Thread Dr.Ruud
Oliver Block schreef: > Sonika Sachdeva: >> How do I use variable string value as a regular expression? > > print $line if $line =~ /$pattern/; Often you want to have special characters quoted: /\Q$pattern\E/ and print for $line; See also qr// in perlop. -- Affijn, Ruud "Gewoon is een t

RE: Perl regular exp

2006-04-11 Thread Ankur Gupta
Sonika Sachdeva scribbled on Tuesday, April 11, 2006 4:27 PM: > Actually I am looking for AND and OR combinations..and the number of > words are not fixed. > ie @words is the variable and I need to have OR and AND combinations > of @words. to match in LINES How do I go

RE: Perl regular exp

2006-04-11 Thread Wagner, David --- Senior Programmer Analyst --- WGO
Analyst --- WGO Cc: Peter Cornelius; beginners@perl.org Subject: Re: Perl regular exp Actually I am looking for AND and OR combinations..and the number of words are not fixed. ie @words is the variable and I need to have OR and AND combinations of @words. to match in LINES How do I go about it?

Re: Perl regular exp

2006-04-11 Thread Oliver Block
Am Mittwoch, 12. April 2006 01:27 schrieb Sonika Sachdeva: > Actually I am looking for AND and OR combinations..and the number of words > are not fixed. > ie @words is the variable and I need to have OR and AND combinations of > @words. to match in LINES > How do I go about it? /abc|def|ghi/ matc

Re: Perl regular exp

2006-04-11 Thread Sonika Sachdeva
Actually I am looking for AND and OR combinations..and the number of words are not fixed. ie @words is the variable and I need to have OR and AND combinations of @words. to match in LINES How do I go about it? On 4/11/06, Wagner, David --- Senior Programmer Analyst --- WGO < [EMAIL PROTECTED]> wr

Re: Perl regular exp

2006-04-11 Thread Peter Cornelius
But I'll bet you don't have @LINES containing all 3 words separated by 2 '&' symbols. You need to break this up into: if($line =~ /$pattern1/ && $line =~ /$pattern2/) { ... } or something similar. On Apr 11, 2006, at 4:15 PM, Sonika Sachdeva wrote: my $querystring="$str1 && $str2 && $str

RE: Perl regular exp

2006-04-11 Thread Wagner, David --- Senior Programmer Analyst --- WGO
Sonika Sachdeva wrote: > $str1=shift; > $str2=shift; > $str3=shift; > > my $querystring="$str1 && $str2 && $str3"; > > foreach (@LINES){ > push @output,$_ if /$querystring/ ; > } > Correct because unless you have abc && efg && hij in the $_ it will not work because that

Re: Perl regular exp

2006-04-11 Thread Oliver Block
Am Mittwoch, 12. April 2006 01:15 schrieb Sonika Sachdeva: > $str1=shift; > $str2=shift; > $str3=shift; > > > foreach (@LINES){ > push @output,$_ if /$querystring/ ; > } > > does not work even if I have @LINES containing all 3 words. .. pursh @output, $_ if(/$str1/ && /$str2/ && /$s

Re: Perl regular exp

2006-04-11 Thread Sonika Sachdeva
words to match are variable e.g array @words On 4/11/06, Sonika Sachdeva <[EMAIL PROTECTED]> wrote: > > $str1=shift; > $str2=shift; > $str3=shift; > > my $querystring="$str1 && $str2 && $str3"; > > foreach (@LINES){ > push @output,$_ if /$querystring/ ; > } > > does not work even i

Re: Perl regular exp

2006-04-11 Thread Sonika Sachdeva
$str1=shift; $str2=shift; $str3=shift; my $querystring="$str1 && $str2 && $str3"; foreach (@LINES){ push @output,$_ if /$querystring/ ; } does not work even if I have @LINES containing all 3 words. Thanx, On 4/11/06, Peter Cornelius <[EMAIL PROTECTED]> wrote: > > What do you me

Re: Perl regular exp

2006-04-11 Thread Peter Cornelius
This matches: my $test_string = 'This is my test string'; my $pattern1 = 'This is'; print "Passed test 1 $/" if ($test_string =~ /$pattern1/); I think that at least part of your problem is the '&&' characters. I'm guessing that you don't mean to match a literal '&&' but that is what your

Re: Perl regular exp

2006-04-11 Thread Oliver Block
Am Mittwoch, 12. April 2006 01:02 schrieb Sonika Sachdeva: > How do I use variable string value as a regular expression? print $line if $line =~ /$pattern/; regards, oliver -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

RE: Perl regular exp

2006-04-11 Thread Ankur Gupta
Sonika Sachdeva scribbled on Tuesday, April 11, 2006 3:39 PM: > Hi , Please state your problem statement. What are you trying to achieve with this program. add use strict; use warnings; at the top of your perl program and then try to run. > print $line if ($line

Re: Perl regular exp

2006-04-11 Thread Peter Cornelius
What do you mean by 'works'? It looks to me like this will print the line if the string 'pattern1 && pattern2 && pattern3' is in the line. Not if pattern1 is in the line and pattern2 is in the line and pattern3 is in the line. Is that what you mean? I think some more detail would help me

Re: Perl regular exp

2006-04-11 Thread Sonika Sachdeva
How do I use variable string value as a regular expression? On 4/11/06, Oliver Block <[EMAIL PROTECTED]> wrote: > > Am Mittwoch, 12. April 2006 00:38 schrieb Sonika Sachdeva: > > my $regex="$pattern1 && $pattern2 && $pattern3"; > > print $line if ($line =~ /$regex/); > > > > doesn't work... > Why

Re: Perl regular exp

2006-04-11 Thread Oliver Block
Am Mittwoch, 12. April 2006 00:38 schrieb Sonika Sachdeva: > my $regex="$pattern1 && $pattern2 && $pattern3"; > print $line if ($line =~ /$regex/); > > doesn't work... Why should it work? regards, Oliver -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PRO

Perl regular exp

2006-04-11 Thread Sonika Sachdeva
Hi , print $line if ($line =~ /pattern1 && pattern2 && pattern3/); works .. but my $regex="$pattern1 && $pattern2 && $pattern3"; print $line if ($line =~ /$regex/); doesn't work... Any clues ? Thanks,

Re: regular exp

2004-07-21 Thread Jenda Krynicky
From: jack jack <[EMAIL PROTECTED]> > I have 2 variables $last_accessed and $owner_line > > $last_accessed=": Last accessed 20-Apr-04.12:57:30 by > [EMAIL PROTECTED]"; > > $owner_line="Owner: opc_bld : rwx (all)"; > > -From $last_accessed i want the foll output in > variables : > > $vi

regular exp

2004-06-18 Thread jack jack
ALL, I have 2 variables $last_accessed and $owner_line $last_accessed=": Last accessed 20-Apr-04.12:57:30 by [EMAIL PROTECTED]"; $owner_line="Owner: opc_bld : rwx (all)"; -From $last_accessed i want the foll output in variables : $view_day=20 $view_month=Apr $view_year=04 -From

Re: Regular Exp for Numerics

2004-01-12 Thread Rob Dixon
Hi Mallik. You asked this question yesterday. Here is a copy of my answer to yesterday's post. Rob Mallik wrote: > > I have to compare numeric values as below > > if (($segsep == 13) || ($segsep == 10) || ($segsep == 0)) > > Can I use the reg exp as below > > if ($segsep =~ /^(13|10|0)$/) > > M

Regular Exp for Numerics

2004-01-12 Thread Mallik
Dear Friends, I have to compare numeric values as below if (($segsep == 13) || ($segsep == 10) || ($segsep == 0)) Can I use the reg exp as below if ($segsep =~ /^(13|10|0)$/) My question is, is it adviceable to use reg exp for numeric values (entire value). If yes, why? If not, why? Thank you

Re: Regular Exp for Numerics

2004-01-11 Thread Rob Dixon
Mallik wrote: > > I have to compare numeric values as below > > if (($segsep == 13) || ($segsep == 10) || ($segsep == 0)) > > Can I use the reg exp as below > > if ($segsep =~ /^(13|10|0)$/) > > My question is, is it adviceable to use reg exp for numeric values (entire > value). > If yes, why? > If

Regular Exp for Numerics

2004-01-11 Thread Mallik
Dear Friends, I have to compare numeric values as below if (($segsep == 13) || ($segsep == 10) || ($segsep == 0)) Can I use the reg exp as below if ($segsep =~ /^(13|10|0)$/) My question is, is it adviceable to use reg exp for numeric values (entire value). If yes, why? If not, why? Thank you

Re: regular exp problem

2003-03-05 Thread Ramprasad
Rob Dixon wrote: Ramprasad wrote: I have a str that contains the base64 encoded string of a mail. Now this string should not contain any characters with ascii values above 128. Can i write a regex to check this Assuming you mean 'above 127' you can use the POSIX ASCII character class: die "I

Re: regular exp problem

2003-03-05 Thread Rob Dixon
Ramprasad wrote: > I have a str that contains the base64 encoded string of a mail. Now > this string should not contain any characters with ascii values above > 128. Can i write a regex to check this Assuming you mean 'above 127' you can use the POSIX ASCII character class: die "Invalid chara

regular exp problem

2003-03-05 Thread Ramprasad
I have a str that contains the base64 encoded string of a mail. Now this string should not contain any characters with ascii values above 128. Can i write a regex to check this thanks ram -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: If Statement Nested Regular Exp.

2002-12-19 Thread Jenda Krynicky
From: "Paul Kraus" <[EMAIL PROTECTED]> > Any ideas why this fails. If I remove if /aged/ and just have the if > /Reports ... then everything works ok. > > Code > #!/usr/bin/perl > my @files; > my %age; > push (@files, glob "Aged*"); > push (@files, glob "Receipts*"); > > foreach (@files){ >

RE: If Statement Nested Regular Exp.

2002-12-19 Thread Wagner, David --- Senior Programmer Analyst --- WGO
]] Sent: Thursday, December 19, 2002 09:12 To: Perl Subject: If Statement Nested Regular Exp. Any ideas why this fails. If I remove if /aged/ and just have the if /Reports ... then everything works ok. Code #!/usr/bin/perl my @files; my %age; push (@files, glob "Aged*"); push (@f

If Statement Nested Regular Exp.

2002-12-19 Thread Paul Kraus
Any ideas why this fails. If I remove if /aged/ and just have the if /Reports ... then everything works ok. Code #!/usr/bin/perl my @files; my %age; push (@files, glob "Aged*"); push (@files, glob "Receipts*"); foreach (@files){ open FILE,"<$_"; print "$_\n"; while(){ if (

Re: regular exp

2002-08-20 Thread David Richardson
Perl has a file globbing operator for situations like this. try @projectFilesExist = <$ja\{*.dsp,*.vbp}>; print "proj already exist\n" if @projectFilesExist; < > returns an array of files matching the pattern between the angle brackets. The @projectFilesExist will be convert to scala

regular exp

2002-08-20 Thread Javeed SAR
Hi, I am getting a path from variable $ja,if i print $ja i get: M:\jav_test\ADT\View_Controller_VB\SDKComponents\ADTModel Note: this path varies everytime. $file=`ls $ja`; If i excute above statement ,In the directory ADTModel, i get a list of files,i have to grep for files with extensio

RE: grep and regular exp.

2001-06-06 Thread Jeff 'japhy' Pinyan
On Jun 6, David Blevins said: >my @list1 = grep(/$year\_$month\_.*01\.txt/, @allFiles); >my @list2 = grep(/$year\_$month\_.*01a\.txt/, @allFiles); It is safer to use ${year} than $year\_ because there are some letters which, if backslashed, have entirely different meanings. -- Jeff "j

RE: grep and regular exp.

2001-06-06 Thread David Blevins
Ahhh. So this is more appropriate: my @list1 = grep(/$year\_$month\_.*01\.txt/, @allFiles); my @list2 = grep(/$year\_$month\_.*01a\.txt/, @allFiles); Note to self: I should be using the warnings. Maybe I should write that on my monitor in permanent marker so I don't forget. ;) Thank

Re: grep and regular exp.

2001-06-06 Thread John Joseph Trammell
On Wed, Jun 06, 2001 at 02:02:33PM -0500, David Blevins wrote: [snip] >my @list1 = grep(/$year_$month_.*01\.txt/, @allFiles); >my @list2 = grep(/$year_$month_.*01a\.txt/, @allFiles); [snip] These regexes look for variables $year_ and $month_. Let me guess -- you're not using warnings, r

grep and regular exp.

2001-06-06 Thread David Blevins
For some reason when I am grepping a list like this one, the regular expression doesn't seem to be working. The $year and $month seem to be ignored. The following code prints: 1999_12_stats_log_01.txt1998_07_stats_log_01a.txt It should print only: 1998_07_stats_log_01a.txt #---