Re: Using regular expressions to populate a variable?

2015-01-18 Thread Charles DeRykus
On Sun, Jan 18, 2015 at 9:28 AM, Jim Gibson wrote: > >> On Jan 18, 2015, at 9:03 AM, Mike wrote: >> >> I was able to find match extraction in the perldoc. >> >> Here is a snippet of what I have. >> >> my $insult = ( $mech->text =~ m/Insulter\ (.*)\ Taken/ ); >> print "$insult\n"; >> >> But $insul

Re: Using regular expressions to populate a variable?

2015-01-18 Thread Mike
Thanks. This worked. On 1/18/15 12:28 PM, Jim Gibson wrote: On Jan 18, 2015, at 9:03 AM, Mike wrote: I was able to find match extraction in the perldoc. Here is a snippet of what I have. my $insult = ( $mech->text =~ m/Insulter\ (.*)\ Taken/ ); print "$insult\n"; But $insult is being popula

Re: Using regular expressions to populate a variable?

2015-01-18 Thread Jim Gibson
> On Jan 18, 2015, at 9:03 AM, Mike wrote: > > I was able to find match extraction in the perldoc. > > Here is a snippet of what I have. > > my $insult = ( $mech->text =~ m/Insulter\ (.*)\ Taken/ ); > print "$insult\n"; > > But $insult is being populated with: 1 > > It should be populated wi

Re: Using regular expressions to populate a variable?

2015-01-18 Thread Mike
ong here? Thanks. On 1/18/15 11:49 AM, Mike wrote: Hey everyone, I'm trying to find information on how I can use regular expressions to populate a variable. I want to pull text between one set of characters and another set of characters and use that to populate my variable. Can anyone

Re: Using regular expressions to populate a variable?

2015-01-18 Thread Shawn H Corey
On Sun, 18 Jan 2015 11:49:11 -0500 Mike wrote: > Hey everyone, I'm trying to find information on how I can use regular > expressions to populate a variable. > > I want to pull text between one set of characters and another set of > characters and use that to populate my

Using regular expressions to populate a variable?

2015-01-18 Thread Mike
Hey everyone, I'm trying to find information on how I can use regular expressions to populate a variable. I want to pull text between one set of characters and another set of characters and use that to populate my variable. Can anyone point me in the right direction? Thanks.

Re: Help with regular expressions

2011-05-10 Thread Tiago Hori
> > Hasn't someone already fixed this problem? If there isn't a CPAN module > to > > perform standardized bibliographic reference formatting/parsing. I > haven't > > looked at CPAN; did either of you? If a CPAN module doesn't exist, one > > should! > > > > What standard? > > Kalthoff K (2001) An

Re: Help with regular expressions

2011-05-09 Thread Brian Fraser
On Mon, May 9, 2011 at 6:35 PM, Kenneth Wolcott wrote: > Hasn't someone already fixed this problem? If there isn't a CPAN module to > perform standardized bibliographic reference formatting/parsing. I haven't > looked at CPAN; did either of you? If a CPAN module doesn't exist, one > should! >

Re: Help with regular expressions

2011-05-09 Thread Kenneth Wolcott
On Mon, May 9, 2011 at 12:04, Sandip Bhattacharya < sand...@foss-community.com> wrote: > On Mon, May 9, 2011 at 11:44 PM, Tiago Hori wrote: > > I am trying to write a small script to parse bibliographic references > like > > this: > > > > Morgan, M.J., Wilson, C.E., Crim, L.W., 1999. The effect o

Re: Help with regular expressions

2011-05-09 Thread Sandip Bhattacharya
On Mon, May 9, 2011 at 11:44 PM, Tiago Hori wrote: > I am trying to write a small script to parse bibliographic references like > this: > > Morgan, M.J., Wilson, C.E., Crim, L.W., 1999. The effect of stress on > reproduction in Atlantic cod. J. Fish Biol. 54, 477-488. > > What I want to be able to

Help with regular expressions

2011-05-09 Thread Tiago Hori
Hi List, I am trying to write a small script to parse bibliographic references like this: Morgan, M.J., Wilson, C.E., Crim, L.W., 1999. The effect of stress on reproduction in Atlantic cod. J. Fish Biol. 54, 477-488. What I want to be able to do eventually is parse each name separately and assoc

Re: Regular Expressions Question

2011-04-12 Thread Rob Dixon
On 11/04/2011 15:21, gkl wrote: OK. So if I understood you correctly, given the following (actual) URLs http://beta.images.theglobeandmail.com/archive/01258/election_heads__1258993cl-3.jpg http://storage.canoe.ca/v1/dynamic_resize/?src=http://www.torontosun.com/news/decision2011/2011/04/06/300_

Re: Regular Expressions Question

2011-04-12 Thread C.DeRykus
On Apr 11, 7:21 am, gklc...@googlemail.com (gkl) wrote: > On Apr 10, 11:03 pm, jwkr...@shaw.ca ("John W. Krahn") wrote: stion on regular expressions as my > > > program is working fine but I was just curious. > > > > Say you have the following URLs: > > &g

Re: Regular Expressions Question

2011-04-12 Thread gkl
On Apr 10, 11:03 pm, jwkr...@shaw.ca ("John W. Krahn") wrote: > cityuk wrote: > > Dear All, > > Hello, > > > > > This is more of a generic question on regular expressions as my > > program is working fine but I was just curious. > > > Sa

Re: Regular Expressions Question

2011-04-11 Thread Rob Dixon
On 11/04/2011 06:43, Shlomi Fish wrote: > On Sunday 10 Apr 2011 14:05:49 cityuk wrote: >> >> This is more of a generic question on regular expressions as my >> program is working fine but I was just curious. >> >> Say you have the following URLs: >> &

Re: Regular Expressions Question

2011-04-10 Thread Shlomi Fish
On Sunday 10 Apr 2011 14:05:49 cityuk wrote: > Dear All, > > This is more of a generic question on regular expressions as my > program is working fine but I was just curious. > > Say you have the following URLs: > > http://www.test.com/image.gif > http://www.test.

Re: Regular Expressions Question

2011-04-10 Thread David Christensen
On 04/10/2011 04:05 AM, cityuk wrote: Is there a way to say here is a whole RE, here is another and match the first or the second? Jeffrey E.F. Friedl, 2006, "Mastering Regular Expressions", 3 e., O'Reilly Media, ISBN 978-0-596-52812-6. http://oreilly.com/catalog/97805

Re: Regular Expressions Question

2011-04-10 Thread John W. Krahn
cityuk wrote: Dear All, Hello, This is more of a generic question on regular expressions as my program is working fine but I was just curious. Say you have the following URLs: http://www.test.com/image.gif http://www.test.com/?src=image.gif?width=12 I want to get the type of the image

Regular Expressions Question

2011-04-10 Thread cityuk
Dear All, This is more of a generic question on regular expressions as my program is working fine but I was just curious. Say you have the following URLs: http://www.test.com/image.gif http://www.test.com/?src=image.gif?width=12 I want to get the type of the image, i.e. the string gif. For

Re: Regular expressions question

2009-11-19 Thread mangled...@yahoo.com
> > > Can anyone tell me how to write a regular expression which matches > > > anything _except_ a litteral string ? > One could also use a zero-with negative look-ahead assertion: > > #!/usr/bin/perl -w > > use strict; > > while( my $line = ){ >   if( $line =~ m/^(?!Nomatch)/ ){ >     print "mat

Re: Regular expressions question

2009-11-18 Thread Rob Coops
On Wed, Nov 18, 2009 at 5:05 PM, Thomas Bätzler wrote: > Hi, > > Dermot suggested: > > 2009/11/17 mangled...@yahoo.com : > > > > Can anyone tell me hoq to write a regular expression which matches > > > anything _except_ a litteral string ? > > > > > > For instance, I want to match any line which

AW: Regular expressions question

2009-11-18 Thread Thomas Bätzler
Hi, Dermot suggested: > 2009/11/17 mangled...@yahoo.com : > > Can anyone tell me hoq to write a regular expression which matches > > anything _except_ a litteral string ? > > > > For instance, I want to match any line which does not begin with > > Nomatch.  So in the following : > You would ne

Re: Regular expressions question

2009-11-18 Thread Dermot
2009/11/17 mangled...@yahoo.com : > Hi, Hello, > Can anyone tell me hoq to write a regular expression which matches > anything _except_ a litteral string ? > > For instance, I want to match any line which does not begin with > Nomatch.  So in the following : > > Line1 > Line2 > Nomatch

Regular expressions question

2009-11-18 Thread mangled...@yahoo.com
Hi, Can anyone tell me hoq to write a regular expression which matches anything _except_ a litteral string ? For instance, I want to match any line which does not begin with Nomatch. So in the following : Line1 Line2 Nomatch Line3 Line 4 I would match every line except

Re: Regular Expressions with Incremented Variable Embedded

2009-06-01 Thread Dr.Ruud
Raabe, Wesley wrote: I am using regular expressions to alter a text file. Where my original file has three spaces to start a paragraph, I want to replace each instance of three spaces with a bracketed paragraph number, with a counter for paragraph numbers, , , etc. [...] The WHILE loop that

Re: Regular Expressions with Incremented Variable Embedded

2009-05-30 Thread John W. Krahn
Raabe, Wesley wrote: I am using regular expressions to alter a text file. Where my original file has three spaces to start a paragraph, I want to replace each instance of three spaces with a bracketed paragraph number, with a counter for paragraph numbers, , , etc. The PERL program that I&#

Re: Regular Expressions with Incremented Variable Embedded

2009-05-30 Thread Chas. Owens
On Sat, May 30, 2009 at 23:32, Raabe, Wesley wrote: > > I am using regular expressions to alter a text file. Where my original file > has three spaces to start a paragraph, I want to replace each instance of > three spaces with a bracketed paragraph number, with a counter f

Regular Expressions with Incremented Variable Embedded

2009-05-30 Thread Raabe, Wesley
I am using regular expressions to alter a text file. Where my original file has three spaces to start a paragraph, I want to replace each instance of three spaces with a bracketed paragraph number, with a counter for paragraph numbers, , , etc. The PERL program that I'm using is model

Re: \w regular expressions unicode

2009-04-24 Thread Jay Savage
On Fri, Apr 24, 2009 at 3:53 PM, Chas. Owens wrote: > 2009/4/24 Jay Savage : > snip >>> Hmm, I don't think it would reparse the whole file, but >>> it does run in a BEGIN block...hmm, I must test it. >>> >> >> It runs in a begin block, but it is still lexically scoped. Pragmata >> are very special

Re: \w regular expressions unicode

2009-04-24 Thread Chas. Owens
On Fri, Apr 24, 2009 at 15:53, Chas. Owens wrote: snip > All of this is good information, but for one thing: not all pragmas > are lexically scoped.  Hence the need to test and/or read the docs. > For instance, the re pragma[1] is only partially lexical: > > #!/usr/bin/perl > > use strict; > use w

Re: \w regular expressions unicode

2009-04-24 Thread Chas. Owens
2009/4/24 Jay Savage : snip >> Hmm, I don't think it would reparse the whole file, but >> it does run in a BEGIN block...hmm, I must test it. >> > > It runs in a begin block, but it is still lexically scoped. Pragmata > are very special cases of modules that provide modifications of > compile-time

Re: \w regular expressions unicode

2009-04-24 Thread Jay Savage
On Wed, Apr 22, 2009 at 6:12 PM, Chas. Owens wrote: > On Wed, Apr 22, 2009 at 17:54, Gunnar Hjalmarsson wrote: >> Chas. Owens wrote: >>> >>> On Wed, Apr 22, 2009 at 15:25, Gunnar Hjalmarsson >>> wrote: >>> snip >>> The utf8 pragma affects the whole file, >> >> Well, only the part of the file th

Re: \w regular expressions unicode

2009-04-22 Thread Chas. Owens
On Wed, Apr 22, 2009 at 18:12, Chas. Owens wrote: > On Wed, Apr 22, 2009 at 17:54, Gunnar Hjalmarsson wrote: >> Chas. Owens wrote: >>> >>> On Wed, Apr 22, 2009 at 15:25, Gunnar Hjalmarsson >>> wrote: >>> snip > > Yeah, it looks so. With "use utf8" (http://perldoc.perl.org/utf8.html)

Re: \w regular expressions unicode

2009-04-22 Thread Chas. Owens
On Wed, Apr 22, 2009 at 17:54, Gunnar Hjalmarsson wrote: > Chas. Owens wrote: >> >> On Wed, Apr 22, 2009 at 15:25, Gunnar Hjalmarsson >> wrote: >> snip Yeah, it looks so. With "use utf8" (http://perldoc.perl.org/utf8.html) one can however make them parsed (decoded) (provided t

Re: \w regular expressions unicode

2009-04-22 Thread Gunnar Hjalmarsson
Chas. Owens wrote: On Wed, Apr 22, 2009 at 15:25, Gunnar Hjalmarsson wrote: snip Yeah, it looks so. With "use utf8" (http://perldoc.perl.org/utf8.html) one can however make them parsed (decoded) (provided they are valid UTF-8). No. The utf8 pragma is about allowing UTF-8 encoded *symbols*, e.g

Re: \w regular expressions unicode

2009-04-22 Thread Gunnar Hjalmarsson
Stanisław T. Findeisen wrote: I mean this: #!/usr/bin/perl use warnings; use strict; # use utf8; use Encode; my $utf8_encoded = "smörgåsbord"; print('is_utf8: ' . (Encode::is_utf8($utf8_encoded) ? 'TRUE' : 'FALSE') . "\n"); This outputs "FALSE" here, but uncomment "use utf8" and it gets "TR

Re: \w regular expressions unicode

2009-04-22 Thread Chas. Owens
On Wed, Apr 22, 2009 at 15:25, Gunnar Hjalmarsson wrote: snip >> Yeah, it looks so. With "use utf8" (http://perldoc.perl.org/utf8.html) one >> can however make them parsed (decoded) (provided they are valid UTF-8). > > No. The utf8 pragma is about allowing UTF-8 encoded *symbols*, e.g. variable >

Re: \w regular expressions unicode

2009-04-22 Thread Stanisław T. Findeisen
Gunnar Hjalmarsson wrote: Or did you possibly mean the utf8::decode() function? I mean this: #!/usr/bin/perl use warnings; use strict; # use utf8; use Encode; my $utf8_encoded = "smörgåsbord"; print('is_utf8: ' . (Encode::is_utf8($utf8_encoded) ? 'TRUE' : 'FALSE') . "\n"); This outputs "F

Re: \w regular expressions unicode

2009-04-22 Thread Gunnar Hjalmarsson
Gunnar Hjalmarsson wrote: Stanisław T. Findeisen wrote: With "use utf8" (http://perldoc.perl.org/utf8.html) one can however make them parsed (decoded) (provided they are valid UTF-8). No. The utf8 pragma is about allowing UTF-8 encoded *symbols*, e.g. variable names or subroutine names. Or

Re: \w regular expressions unicode

2009-04-22 Thread Gunnar Hjalmarsson
Stanisław T. Findeisen wrote: Gunnar Hjalmarsson wrote: What assumptions does Perl make regarding input file (i.e., the program/script file) encoding? AFAIK, it just converts the bytes into Perl's internal format, but it does not assume anything (at least not by default) with respect to the

Re: \w regular expressions unicode

2009-04-22 Thread Stanisław T. Findeisen
Gunnar Hjalmarsson wrote: What assumptions does Perl make regarding input file (i.e., the program/script file) encoding? AFAIK, it just converts the bytes into Perl's internal format, but it does not assume anything (at least not by default) with respect to the character encoding. Is it so

Re: \w regular expressions unicode

2009-04-22 Thread Gunnar Hjalmarsson
Stanisław T. Findeisen wrote: Gunnar Hjalmarsson wrote: Stanisław T. Findeisen wrote: Hi how to write regular expressions matching against Unicode (eg., UTF-8) strings? For instance, in my regexp: qr/^([.<>@ \w])*$/ Decode the UTF-8 encoded strings before applying the regex o

Re: \w regular expressions unicode

2009-04-22 Thread Stanisław T. Findeisen
Gunnar Hjalmarsson wrote: Stanisław T. Findeisen wrote: Hi how to write regular expressions matching against Unicode (eg., UTF-8) strings? For instance, in my regexp: qr/^([.<>@ \w])*$/ Decode the UTF-8 encoded strings before applying the regex on them. $ perl -MEncode -le ' $u

Re: \w regular expressions unicode

2009-04-18 Thread Gunnar Hjalmarsson
Stanisław T. Findeisen wrote: Hi how to write regular expressions matching against Unicode (eg., UTF-8) strings? For instance, in my regexp: qr/^([.<>@ \w])*$/ Decode the UTF-8 encoded strings before applying the regex on them. $ perl -MEncode -le ' $utf8_encoded = "

\w regular expressions unicode

2009-04-18 Thread Stanisław T. Findeisen
Hi how to write regular expressions matching against Unicode (eg., UTF-8) strings? For instance, in my regexp: qr/^([.<>@ \w])*$/ I am using \w because here: http://perldoc.perl.org/perlretut.html it says: === \w mat

Re: Regular Expressions

2009-02-08 Thread Gunnar Hjalmarsson
Chas. Owens wrote: On Sun, Feb 8, 2009 at 03:49, Gunnar Hjalmarsson wrote: Sorry, but I fail too see how using the s/// operator to extract the date field would be so much more confusing and fragile compared to split() + join(). You are calling three functions (one of which is split) and assi

Re: Regular Expressions

2009-02-08 Thread Chas. Owens
On Sun, Feb 8, 2009 at 03:49, Gunnar Hjalmarsson wrote: > Chas. Owens wrote: >> >> On Sat, Feb 7, 2009 at 19:11, Gunnar Hjalmarsson >> wrote: >>> >>> TMTOWTDI >>> >>> use Time::Local; >>> while () { >>> s{,(.+?),}{ >>> my ($d, $m, $y) = split /\//, $1; >>> my $t = ti

Re: Regular Expressions

2009-02-08 Thread Gunnar Hjalmarsson
Chas. Owens wrote: On Sat, Feb 7, 2009 at 19:11, Gunnar Hjalmarsson wrote: TMTOWTDI use Time::Local; while () { s{,(.+?),}{ my ($d, $m, $y) = split /\//, $1; my $t = timelocal 0, 0, 0, $d, $m-1, $y; ($d, $m, $y) = (localtime $t)[3..5]; s

Re: Regular Expressions

2009-02-07 Thread Chas. Owens
On Sat, Feb 7, 2009 at 19:11, Gunnar Hjalmarsson wrote: > Chas. Owens wrote: >> >> On Sat, Feb 7, 2009 at 16:09, Gunnar Hjalmarsson >> wrote: >>> >>> Chas. Owens wrote: This isn't a job for a regex; it is a job for split: >>> >>> whose first argument is a regex pattern... ;-) >> >> snip

Re: Regular Expressions

2009-02-07 Thread Chas. Owens
On Sat, Feb 7, 2009 at 19:21, Rob Dixon wrote: snip > $record =~ s|,(..)/(..)/(),|,$3$1$2,| or die "Data problem"; snip Yes, but how would you handle it if this weren't the second field? It is better to have a general solution. -- Chas. Owens wonkden.net The most important skill a program

Re: Regular Expressions

2009-02-07 Thread Rob Dixon
Chas. Owens wrote: > On Sat, Feb 7, 2009 at 08:45, Soham Das wrote: >> Hi All, >> >> I am a noob in Perl and hence would like some help to what I am sure is a >> very easy problem. >> >> I have got a text file in csv format >> The format is: >> ,,, >> >> Now my objective is to change the for

Re: Regular Expressions

2009-02-07 Thread Gunnar Hjalmarsson
Chas. Owens wrote: On Sat, Feb 7, 2009 at 16:09, Gunnar Hjalmarsson wrote: Chas. Owens wrote: This isn't a job for a regex; it is a job for split: whose first argument is a regex pattern... ;-) snip Yes and a regex follows in the substitute, but the whole things isn't being done with a rege

Re: Regular Expressions

2009-02-07 Thread Chas. Owens
On Sat, Feb 7, 2009 at 16:09, Gunnar Hjalmarsson wrote: > Chas. Owens wrote: >> >> This isn't a job for a regex; it is a job for split: > > whose first argument is a regex pattern... ;-) snip Yes and a regex follows in the substitute, but the whole things isn't being done with a regex. Trying to

Re: Regular Expressions

2009-02-07 Thread Gunnar Hjalmarsson
Chas. Owens wrote: This isn't a job for a regex; it is a job for split: whose first argument is a regex pattern... ;-) -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...

Re: Regular Expressions

2009-02-07 Thread Chas. Owens
On Sat, Feb 7, 2009 at 08:45, Soham Das wrote: > Hi All, > > I am a noob in Perl and hence would like some help to what I am sure is a > very easy problem. > > I have got a text file in csv format > The format is: > ,,, > > Now my objective is to change the format of the date, and rename the

Regular Expressions

2009-02-07 Thread Soham Das
Hi All, I am a noob in Perl and hence would like some help to what I am sure is a very easy problem. I have got a text file in csv format The format is: ,,, Now my objective is to change the format of the date, and rename the whole file as a .csv So, my strategy is: I want to read the co

Re: Comparing files with regular expressions

2008-05-05 Thread Rob Dixon
Aaron Rubinstein wrote: > >> Given just the idea of the data, can you improve on that? > > I bet I could! I bet you could too :) > It's interesting how my instinct, when trying to develop a programming > solution, is to wrestle with the problem inside the context of the language. > As a result

Re: Comparing files with regular expressions

2008-05-05 Thread Aaron Rubinstein
> Given just the idea of the data, can you improve on that? I bet I could! It's interesting how my instinct, when trying to develop a programming solution, is to wrestle with the problem inside the context of the language. As a result, the solutions I come up with tend to be shaped by my limited

Re: Comparing files with regular expressions

2008-05-03 Thread Chas. Owens
On Sat, May 3, 2008 at 5:57 PM, Jenda Krynicky <[EMAIL PROTECTED]> wrote: > From: "Chas. Owens" <[EMAIL PROTECTED]> > > > On Sat, May 3, 2008 at 4:42 PM, Jenda Krynicky <[EMAIL PROTECTED]> wrote: > > snip > > > > [stuff about how two arg open is more dangerous than three arg open > > > And that

Re: Comparing files with regular expressions

2008-05-03 Thread Rob Dixon
rubinsta wrote: > Hello, > > I'm a Perl uber-novice and I'm trying to compare two files in order to > exclude items listed on one file from the complete list on the other > file. What I have so far prints out a third file listing everything > that matches the exclude file from the complete file (

Re: Comparing files with regular expressions

2008-05-03 Thread Jenda Krynicky
From: "Chas. Owens" <[EMAIL PROTECTED]> > On Sat, May 3, 2008 at 4:42 PM, Jenda Krynicky <[EMAIL PROTECTED]> wrote: > snip > > > [stuff about how two arg open is more dangerous than three arg open > > And that means you were lucky. If the $file contained something like > > "|rm -rf /" or "rm -rf

Re: Comparing files with regular expressions

2008-05-03 Thread Chas. Owens
On Sat, May 3, 2008 at 4:42 PM, Jenda Krynicky <[EMAIL PROTECTED]> wrote: snip > > [stuff about how two arg open is more dangerous than three arg open > And that means you were lucky. If the $file contained something like > "|rm -rf /" or "rm -rf / |" ... snip Nah, you would be lucky if that wer

Re: Comparing files with regular expressions

2008-05-03 Thread Jenda Krynicky
From: "Chas. Owens" <[EMAIL PROTECTED]> > On Fri, May 2, 2008 at 10:44 AM, rubinsta <[EMAIL PROTECTED]> wrote: > snip > > Any thoughts as to why > > some of the matches are getting missed? > snip > > Not off hand. I will extract your code and do some tests. Can you > send me y

Re: Comparing files with regular expressions

2008-05-02 Thread Chas. Owens
On Fri, May 2, 2008 at 10:44 AM, rubinsta <[EMAIL PROTECTED]> wrote: snip > Any thoughts as to why > some of the matches are getting missed? snip Not off hand. I will extract your code and do some tests. Can you send me your data or is it sensitive? snip > Just out of beginner curiosity, why

Re: Comparing files with regular expressions

2008-05-02 Thread rubinsta
Many thanks, Chas. These are all very helpful (and educational!) suggestions. I adapted your example like so (specifying the all.txt on the command-line): #!/usr/bin/perl use strict; use warnings; open my $ex, "<", "exclude.txt" or die $!; open my $out, ">", "exTest.txt" or die $!; my %exists;

Re: Comparing files with regular expressions

2008-05-02 Thread Chas. Owens
On Thu, May 1, 2008 at 4:09 PM, rubinsta <[EMAIL PROTECTED]> wrote: > Hello, > > I'm a Perl uber-novice and I'm trying to compare two files in order to > exclude items listed on one file from the complete list on the other > file. What I have so far prints out a third file listing everything >

Comparing files with regular expressions

2008-05-02 Thread rubinsta
Hello, I'm a Perl uber-novice and I'm trying to compare two files in order to exclude items listed on one file from the complete list on the other file. What I have so far prints out a third file listing everything that matches the exclude file from the complete file (which I'm hoping will be a d

RE: problem using backslash on brackets in regular expressions

2008-04-22 Thread adarsh.s85
Hello, (snip) I am trying to use the s/// operator to remove it, by doing this: while() { $_ =~ s/\[*\]//; $_ =~ s/\(*\)//; print $_; } (snip) The method used is incorrect. $_ =~ s/\[*\]//; ---> This says that the search is for opening parenthesis (zero or more occurre

Re: problem using backslash on brackets in regular expressions

2008-04-22 Thread Dr.Ruud
Daniel McClory schreef: > while() >{ > $_ =~ s/\[*\]//; > $_ =~ s/\(*\)//; > print $_; >} while ( ) { s/\[.*?\]//; s/\(.*?\)//; print; } -- Affijn, Ruud "Gewoon is een tijger." -- To unsubscribe, e-mail: [EMAIL PROTECTED] For addit

RE: problem using backslash on brackets in regular expressions

2008-04-22 Thread Wagner, David --- Senior Programmer Analyst --- WGO
> -Original Message- > From: Daniel McClory [mailto:[EMAIL PROTECTED] > Sent: Tuesday, April 22, 2008 16:06 > To: beginners@perl.org > Subject: problem using backslash on brackets in regular expressions > > Hi, > > I have files which contain sentences,

problem using backslash on brackets in regular expressions

2008-04-22 Thread Daniel McClory
Hi, I have files which contain sentences, where some lines have extra information inside brackets and parentheses. I would like to delete everything contained within brackets or parentheses, including the brackets. I know that I am supposed to use the backslash to turn off the metachara

Re: Can regular expressions be used as subroutine arguments?

2008-03-08 Thread John W. Krahn
R (Chandra) Chandrasekhar wrote: Hello Folks, I need to make a substitution in place for each element of an array, and I need to do this to two arrays. Currently the relevant code fragment (without pragmas) is: foreach my $element (@cddb_artist) { $element =~ s/^.*?([0-9,a-f

Re: Can regular expressions be used as subroutine arguments?

2008-03-08 Thread Chas. Owens
On Sat, Mar 8, 2008 at 9:59 AM, Dr.Ruud <[EMAIL PROTECTED]> wrote: snip > > 2. Can arbitrary regular expressions, including /PATTERN/REPLACEMENT/ > > versions > > for substitutions, be used as subroutine arguments, and if so, how? > > Store the parts in variable

Re: Can regular expressions be used as subroutine arguments?

2008-03-08 Thread Dr.Ruud
); my @cddb_track = ("abc fedcba09: xyz"); my $re_hex8 = qr/[[:xdigit:]]{8}/; ($_) = m/($re_hex8)(?=:)/ for @cddb_artist, @cddb_track; print for @cddb_artist, @cddb_track; ' 12345678 fedcba09 > 2. Can arbitrary regular expressions, including /PATTERN/REPLACEMENT/ > versi

Can regular expressions be used as subroutine arguments?

2008-03-08 Thread R (Chandra) Chandrasekhar
variables like $1, be used as a subroutine argument, and if so, how? 2. Can arbitrary regular expressions, including /PATTERN/REPLACEMENT/ versions for substitutions, be used as subroutine arguments, and if so, how? TIA. Chandra -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional

Re: entering regular expressions from the keyboard

2007-08-24 Thread Dr.Ruud
Jay Savage schreef: > Dr.Ruud: >>> Christopher Spears: #print $regexp; >> >> Make that >> print qr/$regexp/; > > Not sure where your headed with this. My headed? :) It was an alternative for the commented "debug" line. > First, OP wants to print the input back to the user. And I pre

Re: entering regular expressions from the keyboard

2007-08-23 Thread Jay Savage
On 8/23/07, Jay Savage <[EMAIL PROTECTED]> wrote: > That means the regex is actually being compiled twice. It probably > doesn't, though, make sense to compile the regex before entering the > loop, so perhaps something like: Make that *does* make sense. -- j --

Re: entering regular expressions from the keyboard

2007-08-23 Thread Jay Savage
On 8/21/07, Dr.Ruud <[EMAIL PROTECTED]> wrote: > Jeff Pang schreef: > > Christopher Spears: > > >> print "Enter regular expression: "; > >> chomp(my $regexp = ); > > > > $regexp = quotemeta($regexp); > > Since it specifically asks for a regular expression, I would definitely > not do quotemeta(). >

Re: entering regular expressions from the keyboard

2007-08-21 Thread Dr.Ruud
Jeff Pang schreef: > Christopher Spears: >> print "Enter regular expression: "; >> chomp(my $regexp = ); > > $regexp = quotemeta($regexp); Since it specifically asks for a regular expression, I would definitely not do quotemeta(). >> #print $regexp; Make that print qr/$regexp/; -- Affijn,

Re: entering regular expressions from the keyboard

2007-08-21 Thread Paul Lalli
On Aug 20, 11:28 pm, [EMAIL PROTECTED] (Christopher Spears) wrote: > I'm working on the second exercise of the second > chapter. I'm supposed to write a program that asks > the user to type a regular expression. The program > then uses the regular expression to try to find a > match in the direct

Re: entering regular expressions from the keyboard

2007-08-20 Thread Mr. Shawn H. Corey
Christopher Spears wrote: Hi! I'm trying to get back into Perl again by working through Intermediate Perl. Unfortunately, the Perl part of my brain has atrophied! I'm working on the second exercise of the second chapter. I'm supposed to write a program that asks the user to type a regular

Re: entering regular expressions from the keyboard

2007-08-20 Thread Jeff Pang
-Original Message- >From: Christopher Spears <[EMAIL PROTECTED]> >Sent: Aug 21, 2007 11:28 AM >To: beginners@perl.org >Subject: entering regular expressions from the keyboard > >Hi! > >I'm trying to get back into Perl again by working >through Inter

entering regular expressions from the keyboard

2007-08-20 Thread Christopher Spears
Hi! I'm trying to get back into Perl again by working through Intermediate Perl. Unfortunately, the Perl part of my brain has atrophied! I'm working on the second exercise of the second chapter. I'm supposed to write a program that asks the user to type a regular expression. The program then

Re: regular expressions issue

2007-06-27 Thread Rob Dixon
Amichai Teumim wrote: I created a file called data.txt which contains a bunch of junk, including some IPs. I want $line to be stored in $ip<http://www.tek-tips.com/viewthread.cfm?qid=1382614&page=1#> . It works, except for the regular expressions which should find only IPs. If

Re: regular expressions issue

2007-06-27 Thread Tom Phoenix
On 6/27/07, Amichai Teumim <[EMAIL PROTECTED]> wrote: If I use the regular expression with the grep command in terminal I get only the IPs. Here in Perl I don't get any output. The grep command uses grep's regular expressions, but Perl uses Perl's regular expressio

regular expressions issue

2007-06-27 Thread Amichai Teumim
I created a file called data.txt which contains a bunch of junk, including some IPs. I want $line to be stored in $ip<http://www.tek-tips.com/viewthread.cfm?qid=1382614&page=1#> . It works, except for the regular expressions which should find only IPs. If I use the regular expressio

Re: Using regular expressions with delimitaters

2007-04-12 Thread yaron
sday, April 11, 2007 4:30:58 PM (GMT+0200) Auto-Detected Subject: Using regular expressions with delimitaters Hello, I need to use the delimiter " " , (one blank space). I read perdoc, i try to use this : if ( "8.1.8" =~ /[\d $versao \s]/) But the expression is always true. Wh

Re: Using regular expressions with delimitaters

2007-04-11 Thread Chas Owens
On 4/11/07, Rodrigo Tavares <[EMAIL PROTECTED]> wrote: snip if ( "8.1.8" =~ /$version/) snip You are using the operators incorrectly. It should look like this: if ($version =~ /8\.1\.8/) The form is "variable binding_operator regex". Note that the periods need to be escaped otherwise they w

RE: Using regular expressions with delimitaters

2007-04-11 Thread Moon, John
From: Rodrigo Tavares [mailto:[EMAIL PROTECTED] Sent: Wednesday, April 11, 2007 9:31 AM To: beginners@perl.org Subject: Using regular expressions with delimitaters Hello, I need to use the delimiter " " , (one blank space). I read perdoc, i try to use this : if ( "8.1.8"

Using regular expressions with delimitaters

2007-04-11 Thread Rodrigo Tavares
Hello, I need to use the delimiter " " , (one blank space). I read perdoc, i try to use this : if ( "8.1.8" =~ /[\d $versao \s]/) But the expression is always true. Where is the error ? my code : #!/usr/bin/perl $version=`/usr/local/pgsql/bin/pg_ctl --version`; print $version; if ( "8.1.8" =

Re: grouppin in the regular expressions

2006-10-15 Thread I . B .
right, what was i thinking? thank you. On 10/13/06, John W. Krahn <[EMAIL PROTECTED]> wrote: I.B. wrote: > sorry, I didn't fraze my question correctly. ^ phrase > example : > $line="abcxabcxxabcxxxabc"; > > how to match everything beofre "xxx" but not xx

Re: grouppin in the regular expressions

2006-10-13 Thread John W. Krahn
I.B. wrote: > sorry, I didn't fraze my question correctly. ^ phrase > example : > $line="abcxabcxxabcxxxabc"; > > how to match everything beofre "xxx" but not xxx itself? > the answer i got is to use lookaheads: > > my $line = "abcxxabcxxxabc"; > if ($line =

Re: grouppin in the regular expressions

2006-10-13 Thread I . B .
"matched: $1\n"; } else{ print "failed\n"; } very cool, thanx everyone ~i On 10/13/06, John W. Krahn <[EMAIL PROTECTED]> wrote: > > I.B. wrote: > > Hi nice people, > > Hello, > > > how to specify using regular expressions: match everythin

Re: grouppin in the regular expressions

2006-10-13 Thread John W. Krahn
I.B. wrote: > Hi nice people, Hello, > how to specify using regular expressions: match everything but string (xxx) > > i would do this : > > $line =~ /[^(xxx)]+/; > > but, as it was mentioned before () inside character class is not working. > what is solution here

RE: grouppin in the regular expressions

2006-10-13 Thread Wagner, David --- Senior Programmer Analyst --- WGO
Programmer Analyst FedEx Freight 1.408.323.4225x2224 TEL 1.408.323.4449 FAX http://fedex.com/us -Original Message- From: I.B. [mailto:[EMAIL PROTECTED] Sent: Friday, October 13, 2006 12:03 To: beginners@perl.org Subject: grouppin in the regular expressions Hi nice people, how to

grouppin in the regular expressions

2006-10-13 Thread I . B .
Hi nice people, how to specify using regular expressions: match everything but string (xxx) i would do this : $line =~ /[^(xxx)]+/; but, as it was mentioned before () inside character class is not working. what is solution here? thank you! ~i

Re: Regular expressions

2006-04-26 Thread Косов Евгений
Sombody help me if i give ([a-z]+)(.*)([a-z]+) as input string output i get is $1 is 'silly' $2 is 'silly' $3 is 'silly' this is wrong according to be book i refer please somone clarify me code i used is as below This is correct. first word that matches ([a-z]+) is 'silly'. print "\$1 is

Regular expressions

2006-04-26 Thread badrinath chitrala
HI Sombody help me if i give ([a-z]+)(.*)([a-z]+) as input string output i get is $1 is 'silly' $2 is 'silly' $3 is 'silly' this is wrong according to be book i refer please somone clarify me code i used is as below use strict; use warnings; $_ = '1: A silly sentence (495,a) *BUT* one which w

Re: regular expressions

2006-04-21 Thread John W. Krahn
Bowen, Bruce wrote: > In perldoc under this topic s is listed as "Treat string as a single > line" and m as Treat string as multiples lines". > > If I have text that has varying spaces at the begging of each line, > and I use > > $string =~ s/^\s+//; It will remove the spaces from in from of th

Re: regular expressions

2006-04-21 Thread Xavier Noria
On Apr 21, 2006, at 16:10, Bowen, Bruce wrote: In perldoc under this topic s is listed as "Treat string as a single line" and m as Treat string as multiples lines". If I have text that has varying spaces at the begging of each line, and I use $string =~ s/^\s+//; It will remove the space

  1   2   3   4   >