Re: regex question....

2010-12-05 Thread RW
On Sat, 4 Dec 2010 20:32:57 -0800 Gary Kline kl...@thought.org wrote: On Sat, Dec 04, 2010 at 06:49:45PM -0800, xSAPPYx wrote: Also, the + operator means '1 or more' but needs escaped: %s/[0-9]\+/foo/g Okay. I thought that the + must be perl-only regex... . It's from Extended

Re: regex question....

2010-12-05 Thread Ian Smith
In freebsd-questions Digest, Vol 339, Issue 11, Message: 30 On Sat, 4 Dec 2010 18:23:08 -0800 Gary Kline kl...@thought.org wrote: On Sat, Dec 04, 2010 at 05:56:59PM -0800, per...@pluto.rain.com wrote: Joshua Gimer jgi...@gmail.com wrote: On Sat, Dec 4, 2010 at 5:26 PM, Gary Kline

Re: regex question....

2010-12-05 Thread Gary Kline
On Sun, Dec 05, 2010 at 07:56:30PM +1100, Ian Smith wrote: In freebsd-questions Digest, Vol 339, Issue 11, Message: 30 On Sat, 4 Dec 2010 18:23:08 -0800 Gary Kline kl...@thought.org wrote: On Sat, Dec 04, 2010 at 05:56:59PM -0800, per...@pluto.rain.com wrote: Joshua Gimer jgi...@gmail.com

Re: regex question....

2010-12-05 Thread Randal L. Schwartz
Joshua == Joshua Gimer jgi...@gmail.com writes: Joshua On Sat, Dec 4, 2010 at 5:26 PM, Gary Kline kl...@thought.org wrote: I have tried :1,$/s/[0-9]][0-9][0-9]/foo/g Joshua Why not just %s/[0-9]*/foo/g Because that would turn a line of fred into foofred. :) -- Randal L. Schwartz -

Re: regex question....

2010-12-05 Thread Randal L. Schwartz
Gary == Gary Kline kl...@thought.org writes: Gary %s/[1-0][0-9]*/foo/g Except 1-0 is an empty set. :) -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 mer...@stonehenge.com URL:http://www.stonehenge.com/merlyn/ Smalltalk/Perl/Unix consulting, Technical writing,

Re: regex question....

2010-12-05 Thread Chip Camden
Quoth Polytropon on Sunday, 05 December 2010: PS: See, this is why I keep cheatsheets. ;) That's the fat green book on my shelf. :-) For regex reference, I find this site helpful: http://www.regular-expressions.info/reference.html ... especially regarding differences between

Re: regex question....

2010-12-05 Thread Chip Camden
Quoth RW on Sunday, 05 December 2010: On Sat, 4 Dec 2010 20:32:57 -0800 Gary Kline kl...@thought.org wrote: On Sat, Dec 04, 2010 at 06:49:45PM -0800, xSAPPYx wrote: Also, the + operator means '1 or more' but needs escaped: %s/[0-9]\+/foo/g Okay. I thought that the + must

Re: regex question....

2010-12-05 Thread Gary Kline
On Sun, Dec 05, 2010 at 09:37:58AM -0800, Randal L. Schwartz wrote: Gary == Gary Kline kl...@thought.org writes: Gary %s/[1-0][0-9]*/foo/g Except 1-0 is an empty set. :) Ya, sure, you-betcha! I really did mean a '9'there. For some reason, what I'm thinking

Re: regex question....

2010-12-05 Thread Gary Kline
On Sun, Dec 05, 2010 at 10:11:34AM -0800, Chip Camden wrote: Quoth Polytropon on Sunday, 05 December 2010: PS: See, this is why I keep cheatsheets. ;) That's the fat green book on my shelf. :-) For regex reference, I find this site helpful:

Re: regex question....

2010-12-05 Thread Wayne Sierke
On Sun, 2010-12-05 at 10:19 -0800, Chip Camden wrote: Quoth RW on Sunday, 05 December 2010: On Sat, 4 Dec 2010 20:32:57 -0800 Gary Kline kl...@thought.org wrote: On Sat, Dec 04, 2010 at 06:49:45PM -0800, xSAPPYx wrote: Also, the + operator means '1 or more' but needs escaped:

regex question....

2010-12-04 Thread Gary Kline
Gang, I was tried to find Jeffrey Friedl's email to figure out some quick regex when it struck me that the list can clue me in [[I have figured this out myself several times--well, 3 or 4 anyway--but it was more trial/error than I need.]] I have a file with ints from 0 to some N. What is

Re: regex question....

2010-12-04 Thread Joshua Gimer
On Sat, Dec 4, 2010 at 5:26 PM, Gary Kline kl...@thought.org wrote: I have tried :1,$/s/[0-9]][0-9][0-9]/foo/g Why not just %s/[0-9]*/foo/g -- Thanks, Joshua Gimer --- http://www.linkedin.com/in/jgimer http://twitter.com/jgimer http://itsecops.blogspot.com/

Re: regex question....

2010-12-04 Thread Gary Kline
On Sat, Dec 04, 2010 at 05:29:49PM -0700, Joshua Gimer wrote: On Sat, Dec 4, 2010 at 5:26 PM, Gary Kline kl...@thought.org wrote: I have tried :1,$/s/[0-9]][0-9][0-9]/foo/g Why not just %s/[0-9]*/foo/g So I just missed the *? Didn't need to escape the [ or ] ? ---I'll

Re: regex question....

2010-12-04 Thread Polytropon
On Sat, 4 Dec 2010 17:24:30 -0800, Gary Kline kl...@thought.org wrote: So I just missed the *? Yes. In regex, * means any amount of, if I remember correctly. So you don't have to specify precisely how many numbers there are. How many lights? :-) Didn't need to escape the [ or ] ?

Re: regex question....

2010-12-04 Thread perryh
Joshua Gimer jgi...@gmail.com wrote: On Sat, Dec 4, 2010 at 5:26 PM, Gary Kline kl...@thought.org wrote: I have tried :1,$/s/[0-9]][0-9][0-9]/foo/g Why not just %s/[0-9]*/foo/g Too broad -- it will match the null string. (* means zero or more instances of whatever preceded it.) Best RE I

Re: regex question....

2010-12-04 Thread Gary Kline
On Sat, Dec 04, 2010 at 05:56:59PM -0800, per...@pluto.rain.com wrote: Joshua Gimer jgi...@gmail.com wrote: On Sat, Dec 4, 2010 at 5:26 PM, Gary Kline kl...@thought.org wrote: I have tried :1,$/s/[0-9]][0-9][0-9]/foo/g Why not just %s/[0-9]*/foo/g Too broad -- it will match the null

Re: regex question....

2010-12-04 Thread xSAPPYx
On Sat, Dec 4, 2010 at 17:56, per...@pluto.rain.com wrote: Joshua Gimer jgi...@gmail.com wrote: On Sat, Dec 4, 2010 at 5:26 PM, Gary Kline kl...@thought.org wrote: I have tried :1,$/s/[0-9]][0-9][0-9]/foo/g Why not just %s/[0-9]*/foo/g Too broad -- it will match the null string.  (* means

Re: regex question....

2010-12-04 Thread Gary Kline
On Sat, Dec 04, 2010 at 06:49:45PM -0800, xSAPPYx wrote: On Sat, Dec 4, 2010 at 17:56, per...@pluto.rain.com wrote: Joshua Gimer jgi...@gmail.com wrote: On Sat, Dec 4, 2010 at 5:26 PM, Gary Kline kl...@thought.org wrote: I have tried :1,$/s/[0-9]][0-9][0-9]/foo/g Why not just

Re: Off Topic RegEx Question

2003-08-29 Thread mpd
On Thu, Aug 28, 2003 at 08:26:43AM +0900, Roger Williams wrote: I know thins is not the place but I know one of you know this one off the top of your head. I have: $list = dog 1 1 1 cat 2 1 snake 111 and I want to end up with: dog 1 cat 2 snake 1 I thought $list =~ s/ \d \d/ \d/g;

Re: Off Topic Regex Question

2003-08-29 Thread Mikko Työläjärvi
On Thu, 28 Aug 2003, Roger Williams wrote: I know thins is not the place but I know one of you know this one off the top of your head. I have: $list = dog 1 1 1 cat 2 1 snake 111 and I want to end up with: dog 1 cat 2 snake 1 I thought $list =~ s/ \d \d/ \d/g; would do the trick, but

Off Topic RegEx Question

2003-08-28 Thread Roger Williams
I know thins is not the place but I know one of you know this one off the top of your head. I have: $list = dog 1 1 1 cat 2 1 snake 111 and I want to end up with: dog 1 cat 2 snake 1 I thought $list =~ s/ \d \d/ \d/g; would do the trick, but that gives me: dog d 1 1 cat d snake d 1 Thanks,

Re: Off Topic RegEx Question

2003-08-28 Thread David Landgren
Roger Williams wrote: I know thins is not the place but I know one of you know this one off the top of your head. I have: $list = dog 1 1 1 cat 2 1 snake 111 and I want to end up with: dog 1 cat 2 snake 1 I thought $list =~ s/ \d \d/ \d/g; would do the trick, but that gives me: dog d 1

Off Topic RegEx Question

2003-08-28 Thread Roger Williams
I know thins is not the place but I know one of you know this one off the top of your head. I have: $list = dog 1 1 1 cat 2 1 snake 111 and I want to end up with: dog 1 cat 2 snake 1 I thought $list =~ s/ \d \d/ \d/g; would do the trick, but that gives me: dog d 1 1 cat d snake d 1 Thanks,

Off Topic Regex Question

2003-08-28 Thread Roger Williams
I know thins is not the place but I know one of you know this one off the top of your head. I have: $list = dog 1 1 1 cat 2 1 snake 111 and I want to end up with: dog 1 cat 2 snake 1 I thought $list =~ s/ \d \d/ \d/g; would do the trick, but that gives me: dog d 1 1 cat d snake d 1 Thanks,