Regex one-liner to find several multi-line blocks of text in a single file

2012-11-01 Thread Thomas Smith
Hi, I'm trying to search a file for several matching blocks of text. A sample of what I'm searching through is below. What I want to do is match # START block # through to the next # END block # and repeat that throughout the file without matching any of the text that falls

Re: Regex one-liner to find several multi-line blocks of text in a single file

2012-11-01 Thread Paul Johnson
On Thu, Nov 01, 2012 at 12:44:08AM -0700, Thomas Smith wrote: Hi, I'm trying to search a file for several matching blocks of text. A sample of what I'm searching through is below. What I want to do is match # START block # through to the next # END block # and repeat that

Re: Regex one-liner to find several multi-line blocks of text in a single file

2012-11-01 Thread Jim Gibson
On Nov 1, 2012, at 12:44 AM, Thomas Smith wrote: Hi, I'm trying to search a file for several matching blocks of text. A sample of what I'm searching through is below. What I want to do is match # START block # through to the next # END block # and repeat that throughout

RE: regex one liner

2006-03-22 Thread stu meacham
Good question. I went to a script right away after the difficulty with the one-liner and returned to the command line syntax problem more out of curiosity than anything else. I'm a fan of the command line because once I get one that works all I need is the 'history' command and an up arrow

RE: regex one liner

2006-03-21 Thread stu meacham
perl -i -p -e 's/^(\d{2}\t\d{2}\t\d{2})/g' This was the 1st thing that I tried; it doesn't work. It was initially easy but different things kept appearing that forced me to use 1 statements on the command line. Negating what I want seems like it ought to be simple. What have you

Re: regex one liner

2006-03-21 Thread Jay Savage
On 3/20/06, stu meacham [EMAIL PROTECTED] wrote: perl -i -p -e 's/^(\d{2}\t\d{2}\t\d{2})/g' This was the 1st thing that I tried; it doesn't work. It was initially easy but different things kept appearing that forced me to use 1 statements on the command line. Negating what I want

Re: regex one liner

2006-03-21 Thread stu meacham
I tried one final time with non-capturing parentheses i.e. (?: to no avail. This works just fine however: perl -i -p -e '@matches = m/\d{2}\t\d{2}\t\d{2}/g; s/.*//g; print@matches\n' Retrieve, delete what's left, and rewrite what's to be kept. It should now work everytime all the time.

RE: regex one liner

2006-03-21 Thread Timothy Johnson
:25 AM To: Jay Savage; beginners perl Subject: Re: regex one liner I tried one final time with non-capturing parentheses i.e. (?: to no avail. This works just fine however: perl -i -p -e '@matches = m/\d{2}\t\d{2}\t\d{2}/g; s/.*//g; print@matches\n' Retrieve, delete what's left, and rewrite

Re: regex one liner

2006-03-21 Thread Jay Savage
On 3/21/06, Timothy Johnson [EMAIL PROTECTED] wrote: We run into one of these How do I do this in a one-liner? questions pretty frequently, and I for one have to ask, what exactly makes the one-liner so compelling, especially when you are using it for something that will be run repeatedly?

Re: regex one liner

2006-03-21 Thread Mr. Shawn H. Corey
Timothy Johnson wrote: We run into one of these How do I do this in a one-liner? questions pretty frequently, and I for one have to ask, what exactly makes the one-liner so compelling, especially when you are using it for something that will be run repeatedly? Because you can use them in

RE: regex one liner

2006-03-21 Thread Timothy Johnson
-Original Message- From: Mr. Shawn H. Corey [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 21, 2006 1:36 PM To: beginners perl Subject: Re: regex one liner Timothy Johnson wrote: We run into one of these How do I do this in a one-liner? questions pretty frequently, and I for one have

Re: regex one liner

2006-03-21 Thread Mr. Shawn H. Corey
Timothy Johnson wrote: And you can't do this? alias pcalc='perl ~/pcalc.pl' No. With alias, I can create an alias file that works with sh (and ksh, bash) and csh (and tcsh). This would be dot'ed in your .profile as: . ~/.alias or source'd in your .cshrc as: source ~/.alias If

Re: regex one liner

2006-03-21 Thread Kevin Viel
BTW, out here in the real world (that would be UNIX), *.pl stands for Perl Library file, not a script. What extension do you suggest using, if any, in the real world? Thanks, Kevin -- Kevin Viel Department of Genetics

Re: regex one liner

2006-03-21 Thread Dave Gray
On 3/21/06, Kevin Viel [EMAIL PROTECTED] wrote: BTW, out here in the real world (that would be UNIX), *.pl stands for Perl Library file, not a script. What extension do you suggest using, if any, in the real world? .ps for perl script /snicker -- To unsubscribe, e-mail: [EMAIL PROTECTED]

Re: regex one liner

2006-03-21 Thread Jay Savage
perl Subject: Re: regex one liner Timothy Johnson wrote: We run into one of these How do I do this in a one-liner? questions pretty frequently, and I for one have to ask, what exactly makes the one-liner so compelling, especially when you are using it for something

RE: regex one liner

2006-03-21 Thread Timothy Johnson
-Original Message- From: Mr. Shawn H. Corey [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 21, 2006 2:29 PM To: beginners perl Subject: Re: regex one liner Timothy Johnson wrote: And you can't do this? alias pcalc='perl ~/pcalc.pl' No. With alias, I can create an alias file

RE: regex one liner

2006-03-21 Thread Timothy Johnson
-Original Message- From: Jay Savage [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 21, 2006 3:06 PM To: Timothy Johnson Subject: Re: regex one liner snip And as for the issue of slightly varying regexes as arguments to a script (different email), it may seem easier to you

Re: regex one liner

2006-03-21 Thread Omega -1911
:[EMAIL PROTECTED] Sent: Tuesday, March 21, 2006 2:29 PM To: beginners perl Subject: Re: regex one liner Timothy Johnson wrote: And you can't do this? alias pcalc='perl ~/pcalc.pl' No. With alias, I can create an alias file that works with sh (and ksh, bash) and csh (and tcsh

Re: regex one liner

2006-03-21 Thread Chad Perrin
On Tue, Mar 21, 2006 at 09:27:28AM -0500, Jay Savage wrote: On 3/20/06, stu meacham [EMAIL PROTECTED] wrote: perl -i -p -e 's/^(\d{2}\t\d{2}\t\d{2})/g' This was the 1st thing that I tried; it doesn't work. It was initially easy but different things kept appearing that forced me to

Re: regex one liner

2006-03-21 Thread Chad Perrin
On Tue, Mar 21, 2006 at 04:32:21PM -0700, Chad Perrin wrote: misused the carat. Mea culpa, Jay. I didn't mean to lead you astray. . . . and here I go with the stupid mistakes again. I meant Stu, not Jay. -- Chad Perrin [ CCD CopyWrite | http://ccd.apotheon.org ] Real ugliness is not

Re: regex one liner

2006-03-21 Thread Chad Perrin
On Tue, Mar 21, 2006 at 04:05:17PM -0700, Dave Gray wrote: On 3/21/06, Kevin Viel [EMAIL PROTECTED] wrote: BTW, out here in the real world (that would be UNIX), *.pl stands for Perl Library file, not a script. What extension do you suggest using, if any, in the real world? .ps for

Re: regex one liner

2006-03-21 Thread Mr. Shawn H. Corey
Timothy Johnson wrote: Beyond being rude and immature, this is off-topic. Please don't try to start a my OS is better than your OS war. I wasn't trying to be rude but Perl was developed and evolved in UNIX; something most people don't know. In UNIX, all scripts, whether there are Perl, sh,

Re: regex one liner

2006-03-21 Thread Mr. Shawn H. Corey
Chad Perrin wrote: Actually, I tend to either use no file extension or .plx as the file extension for a non-library script. I'm pretty sure ActivePerl recognizes .plx (not entirely sure, but pretty sure), though I generally do all my scripting on *nix, so it's not really an issue here. In

regex one liner

2006-03-20 Thread stu meacham
I would like to modify a file 'in place' at the command line with regexes. The file changes daily and is messy. Can one negate a regex itself as opposed to a class of regular expressions? If I could remove everything but that selected by m/\d{2}\t\d{2}\t\d{2}/g life would be better as I know

RE: regex one liner

2006-03-20 Thread Timothy Johnson
What have you tried? Have you seen the -i option? -Original Message- From: stu meacham [mailto:[EMAIL PROTECTED] Sent: Monday, March 20, 2006 2:33 PM To: beginners@perl.org Subject: regex one liner I would like to modify a file 'in place' at the command line with regexes. The file

Re: regex one liner

2006-03-20 Thread Jay Savage
On 3/20/06, stu meacham [EMAIL PROTECTED] wrote: I would like to modify a file 'in place' at the command line with regexes. The file changes daily and is messy. Can one negate a regex itself as opposed to a class of regular expressions? If I could remove everything but that selected by