Re: Regular expression question

2010-08-14 Thread C.DeRykus
On Aug 14, 6:28 am, dery...@gmail.com ("C.DeRykus") wrote: > On Aug 13, 1:47 pm, tobias.wage...@googlemail.com (irata) wrote: > > > > > > > I want to replace in a javscript structure like the one below every > > occurence of "{#...}", "{?...}", "{+...}" and "{=...}" through > > something different

Re: Regular expression question

2010-08-14 Thread C.DeRykus
On Aug 13, 1:47 pm, tobias.wage...@googlemail.com (irata) wrote: > > I want to replace in a javscript structure like the one below every > occurence of "{#...}", "{?...}", "{+...}" and "{=...}" through > something different (also nested): >    function() { >       test1 = "{#Caption}"; >       tes

Re: Regular expression question

2010-08-13 Thread Jim Gibson
On 8/13/10 Fri Aug 13, 2010 1:47 PM, "irata" scribbled: > Hi... > > I want to replace in a javscript structure like the one below every > occurence of "{#...}", "{?...}", "{+...}" and "{=...}" through > something different (also nested): Check out the Text::Balanced module, available at CPAN:

Re: Regular expression question

2008-10-07 Thread Rob Dixon
irata wrote: > > can someone explain me, why this short regex don't give the result I > expect: > > perl -e '$text = "(7) 32"; printf "[%s][%s]\n", ( $text =~ /\((\d+) > \)\s+(\d+)/ )' > > I supposed that the output is "[7][32]", but the output is "[][]". I > don't know why... Your regular e

Re: Regular expression question

2008-10-06 Thread Mr. Shawn H. Corey
On Mon, 2008-10-06 at 04:51 -0700, irata wrote: > perl -e '$text = "(7) 32"; printf "[%s][%s]\n", ( $text =~ /\((\d+) > \)\s+(\d+)/ )' $ perl -e '$text = "(7) 32"; printf "[%s][%s]\n", ( $text =~ /\((\d+) > \)\s+(\d+)/ )' [][] $ perl -e '$text = "(7) 32"; printf "[%s][%s]\n", ( $text =~

Re: Regular expression question

2008-10-06 Thread Olteanu Eugen
It looks there is a space there.. # perl -e '$text = "(7) 32"; printf "[%s][%s]\n", ( $text =~ /\((\d+) \)\s+(\d+)/ )' [][] # perl -e '$text = "(7) 32"; printf "[%s][%s]\n", ( $text =~ /\((\d+)\)\s+(\d+)/ )' [7][32] On Mon, Oct 6, 2008 at 2:51 PM, irata <[EMAIL PROTECTED]> wrote: > Hello,

Re: Quoting Style meta-discussion & religious war (was RE: Regular Expression Question)

2008-09-22 Thread Raymond Wan
Hi Thomas, Thomas Bätzler wrote: Mr. Shawn H. Corey <[EMAIL PROTECTED]> sniped with regard to top-posting: Funny that blogs work that way. Do they now? The ones that I tend to read all show the comment section after the article body. I think that depends on the software. I kno

Re: Regular Expression Question

2008-09-22 Thread Raymond Wan
Hi Rob, Rob Dixon wrote: Raymond Wan wrote: Rob Dixon wrote: Rob Coops wrote: I don't mean to sound disrespectful since you're far more helpful to this list than I am -- so, I mean this in the nicest possible way, but I genuinely would like to know -- where does it say th

Quoting Style meta-discussion & religious war (was RE: Regular Expression Question)

2008-09-22 Thread Thomas Bätzler
Mr. Shawn H. Corey <[EMAIL PROTECTED]> sniped with regard to top-posting: > Funny that blogs work that way. Do they now? The ones that I tend to read all show the comment section after the article body. Cheers, Thomas -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail:

Re: Regular Expression Question

2008-09-22 Thread Paul Johnson
On Mon, Sep 22, 2008 at 02:52:17PM +0100, Rob Dixon wrote: > There are people who oversee this list. The shame is they let pretty much > everything by, in fact I haven't seen an intervention in the last year. The FAQ is at http://learn.perl.org/faq/beginners.html As you can see, it hasn't been u

Re: Regular Expression Question

2008-09-22 Thread Rob Dixon
Raymond Wan wrote: > > Rob Dixon wrote: >> >> Rob Coops wrote: >> >>> You are almost there but not quite... >>> >> [snip] >> >> I despair of saying this. >> >> Please bottom-post your replies (i.e. beneath the text that you are quoting.) >> Top-posting is fine for a short thread, but it ge

Re: Regular Expression Question

2008-09-22 Thread Rob Dixon
Rob Coops wrote: > > Ok, ok, I get it. it will not happen again, sorry all. > > :-) It's fine. I asked the same question about four years ago. People get heated about it because it is very plainly the right way to do things but we get weary of saying it over and over again. Same goes for chompin

Re: Regular Expression Question

2008-09-22 Thread Rob Dixon
Mr. Shawn H. Corey wrote: > On Mon, 2008-09-22 at 08:31 -0400, Jack Gates wrote: >> Would you want to come along later and have to scroll to the bottom to >> read >> the first post. Scroll down a little as you read then scroll up to >> read the >> reply etc., etc., etc. until you are back at the

Re: Regular Expression Question

2008-09-22 Thread Rob Coops
On Mon, Sep 22, 2008 at 2:48 PM, Jack Gates <[EMAIL PROTECTED]> wrote: > On Monday 22 September 2008 08:42:51 am Mr. Shawn H. Corey wrote: > > On Mon, 2008-09-22 at 08:31 -0400, Jack Gates wrote: > > > Would you want to come along later and have to scroll to the bottom to > > > read > > > the firs

Re: Regular Expression Question

2008-09-22 Thread Jack Gates
On Monday 22 September 2008 08:42:51 am Mr. Shawn H. Corey wrote: > On Mon, 2008-09-22 at 08:31 -0400, Jack Gates wrote: > > Would you want to come along later and have to scroll to the bottom to > > read > > the first post. Scroll down a little as you read then scroll up to > > read the > > reply

Re: Regular Expression Question

2008-09-22 Thread Mr. Shawn H. Corey
On Mon, 2008-09-22 at 08:31 -0400, Jack Gates wrote: > Would you want to come along later and have to scroll to the bottom to > read > the first post. Scroll down a little as you read then scroll up to > read the > reply etc., etc., etc. until you are back at the top? > Funny that blogs work th

Re: Regular Expression Question

2008-09-22 Thread Rob Dixon
Thomas Bätzler wrote: > > Raymond Wan <[EMAIL PROTECTED]> wrote: >> >> I looked a bit for some etiquette list for this mailing list >> and couldn't find out. Perhaps it's out there somewhere? > > You could argue that in absence of any other rules, RFC 1855 applies: > > "If you are sending a rep

Re: Regular Expression Question

2008-09-22 Thread Jack Gates
On Monday 22 September 2008 08:18:27 am Rob Dixon wrote: > Thomas Bätzler wrote: > > Raymond Wan <[EMAIL PROTECTED]> wrote: > >> I looked a bit for some etiquette list for this mailing list > >> and couldn't find out. Perhaps it's out there somewhere? > > > > You could argue that in absence of any

RE: Regular Expression Question

2008-09-22 Thread Thomas Bätzler
Raymond Wan <[EMAIL PROTECTED]> wrote: > I looked a bit for some etiquette list for this mailing list > and couldn't find out. Perhaps it's out there somewhere? You could argue that in absence of any other rules, RFC 1855 applies: "If you are sending a reply to a message or a posting be sure yo

Re: Regular Expression Question

2008-09-22 Thread Raymond Wan
Dear Rob, Rob Dixon wrote: Rob Coops wrote: You are almost there but not quite... [snip] I despair of saying this. Please bottom-post your replies (i.e. beneath the text that you are quoting.) Top-posting is fine for a short thread, but it gets to be an unintelligible mess if there

Re: Regular Expression Question

2008-09-22 Thread Rob Dixon
Rob Coops wrote: > > You are almost there but not quite... [snip] I despair of saying this. Please bottom-post your replies (i.e. beneath the text that you are quoting.) Top-posting is fine for a short thread, but it gets to be an unintelligible mess if there are several replies. Bottom-posting

Re: Regular Expression Question

2008-09-22 Thread Rob Coops
You are almost there but not quite... $string =~ s/\~(.*)\~/$1<\/i>/g; Should do the trick. All I do is capture the "someString" part and rewrite it (it is stored in $1 for the first capture and $2 for the second and so on..) This way ~anystring~ will be replaced with anyString There is one more

Re: regular expression question

2007-12-05 Thread John W . Krahn
On Wednesday 05 December 2007 09:53, Perl WANNABE wrote: > * Dr.Ruud <[EMAIL PROTECTED]> [2007-12-02 14:34]: > > John W . Krahn schreef: > > > Eric Krause: > > > > > > $ perl -le' > > > $_ = q[1xxx1111xx11x1]; > > > print; > > > s/(1+)/@{[($l=$1)=~y|1|1|]}/g; > > > print; > > > ' >

Re: regular expression question

2007-12-05 Thread Perl WANNABE
* Dr.Ruud <[EMAIL PROTECTED]> [2007-12-02 14:34]: > John W . Krahn schreef: > > Eric Krause: > > > $ perl -le' > > $_ = q[1xxx1111xx11x1]; > > print; > > s/(1+)/@{[($l=$1)=~y|1|1|]}/g; > > print; > > ' > > 1xxx1111xx11x1 > > 5xxx26xx2x1 > > :-) > > Aiaiaiai

Re: regular expression question

2007-12-02 Thread Rob Dixon
Eric Krause wrote: > Hello all, I have a string like: 1xxx1111xx11x1 I would like to replace the 1's with the total of 1's like this: 5xxx26xx2x1 Can anyone please help? Simply: $string =~ s/(1+)/length $1/ge; HTH, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED]

Re: regular expression question

2007-12-02 Thread Tom Phoenix
On 12/1/07, Eric Krause <[EMAIL PROTECTED]> wrote: >for ($n = 8; $n <=1; $n--) { $n <= 1? Because using the three-part for loop can be error-prone, in Perl we more often use the foreach loop, which is easier to get right on the first try: foreach my $n (reverse 1..8) { ... } Hope th

Re: regular expression question

2007-12-02 Thread Paul Johnson
On Sun, Dec 02, 2007 at 12:14:58AM -0500, Eric Krause wrote: >> $ perl -le' >> $_ = q[1xxx1111xx11x1]; >> print; >> s/(1+)/@{[($l=$1)=~y|1|1|]}/g; >> print; >> ' >> 1xxx1111xx11x1 >> 5xxx26xx2x1 >> >> >> >> :-) >> >> John >> > John, > That worked perfectl

Re: regular expression question

2007-12-02 Thread Dr.Ruud
John W . Krahn schreef: > Eric Krause: >> I have a string like: >> 1xxx1111xx11x1 >> >> I would like to replace the 1's with the total of 1's like this: >> 5xxx26xx2x1 > > > $ perl -le' > $_ = q[1xxx1111xx11x1]; > print; > s/(1+)/@{[($l=$1)=~y|1|1|]}/g; >

Re: regular expression question

2007-12-02 Thread Eric Krause
Thanks Tom. It's not homework. I'm trying to parse html chess notation from a site into FEN. I labeled the blank spaces 1, now I need to add them up wherever they occur. Just for fun. What I have tried failed miserably and I'm not sure why. for ($n = 8; $n <=1; $n--) { if ($temp =

Re: regular expression question

2007-12-02 Thread Eric Krause
$ perl -le' $_ = q[1xxx1111xx11x1]; print; s/(1+)/@{[($l=$1)=~y|1|1|]}/g; print; ' 1xxx1111xx11x1 5xxx26xx2x1 :-) John John, That worked perfectly! Thanks!!! Cheers, Eric -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-ma

Re: regular expression question

2007-12-01 Thread John W . Krahn
On Saturday 01 December 2007 18:16, Eric Krause wrote: > > Hello all, Hello, > I have a string like: > 1xxx1111xx11x1 > > I would like to replace the 1's with the total of 1's like this: > 5xxx26xx2x1 $ perl -le' $_ = q[1xxx1111xx11x1]; print; s/(1+)/@{[(

Re: regular expression question

2007-12-01 Thread Tom Phoenix
On 12/1/07, Eric Krause <[EMAIL PROTECTED]> wrote: > I have a string like: > 1xxx1111xx11x1 > > I would like to replace the 1's with the total of 1's like this: > 5xxx26xx2x1 Hmmm Smells like homework. What have you tried so far? Your missing pieces of the puzzle may

Re: regular expression question

2006-09-08 Thread David Romano
chen li wrote on Fri, Sep 08, 2006 at 09:34:03AM PDT: > One more question about this regex: > > @data = m/(\D+[^\d\s]|\d+)/g; > > I check Programming Perl or perldoc they say ^ is used > as an anchor meaning "start/begining with". But here > looks like it has a different usage. Is that right? Yes

Re: regular expression question

2006-09-08 Thread chen li
--- David Romano <[EMAIL PROTECTED]> wrote: > chen li wrote on Thu, Sep 07, 2006 at 01:13:04PM > PDT: > > > > > One more question what if I have a file that > have > > > > different lines 1) some lines have number only > 2) > > > some > > > > lines have more than 2 words at the begining? > > >

Re: regular expression question

2006-09-07 Thread chen li
> On 9/7/06, chen li <[EMAIL PROTECTED]> wrote: > > Hi Adriano, > > > > The line code you provide doesn't work on my > computer > > but based on what you say I change it into this > line > > code and it works. > > > On 9/7/06, Rob Dixon <[EMAIL PROTECTED]> wrote: > > Why did I have to test this c

Re: regular expression question

2006-09-07 Thread Adriano Ferreira
On 9/7/06, Rob Dixon <[EMAIL PROTECTED]> wrote: It's very bad form to post something to the list that simply doesn't work. This won't even compile: Type of arg 1 to shift must be array (not concatenation (.) or string) at E:\Perl\source\xx.pl line 2, near "" ")" Ok, my fault. I was hasty to

Re: regular expression question

2006-09-07 Thread Rob Dixon
chen li wrote: > > I need a regular expression to process some data but > get stuck. I wonder if anyone here might have a clue. > > input: > my $line='group A 1 2 3 4';# separated by space > > results: > my @data=("group A ",1,2,3,4); My offering: my @data = $line =~ /\S+/g; splice @data

Re: regular expression question

2006-09-07 Thread Rob Dixon
Adriano Ferreira wrote: > > On 9/6/06, chen li <[EMAIL PROTECTED]> wrote: > >> I need a regular expression to process some data but >> get stuck. I wonder if anyone here might have a clue. >> >> input: >> my $line='group A 1 2 3 4';# separated by space >> >> results: >> my @data=("group A ",1,

Re: regular expression question

2006-09-06 Thread David Romano
chen li wrote on Wed, Sep 06, 2006 at 08:23:42PM PDT: > --- Adriano Ferreira <[EMAIL PROTECTED]> wrote: > > On 9/6/06, chen li <[EMAIL PROTECTED]> wrote: > > > I need a regular expression to process some data > > but > > > get stuck. I wonder if anyone here might have a > > clue. > > > > > > input

Re: regular expression question

2006-09-06 Thread Mumia W.
On 09/06/2006 09:49 PM, chen li wrote: Hello all, I need a regular expression to process some data but get stuck. I wonder if anyone here might have a clue. input: my $line='group A 1 2 3 4';# separated by space results: my @data=("group A ",1,2,3,4); As Adriano Ferreira said, you don

Re: regular expression question

2006-09-06 Thread chen li
--- Adriano Ferreira <[EMAIL PROTECTED]> wrote: > On 9/6/06, chen li <[EMAIL PROTECTED]> wrote: > > I need a regular expression to process some data > but > > get stuck. I wonder if anyone here might have a > clue. > > > > input: > > my $line='group A 1 2 3 4';# separated by space > > > > res

Re: regular expression question

2006-09-06 Thread Adriano Ferreira
On 9/6/06, chen li <[EMAIL PROTECTED]> wrote: I need a regular expression to process some data but get stuck. I wonder if anyone here might have a clue. input: my $line='group A 1 2 3 4';# separated by space results: my @data=("group A ",1,2,3,4); You barely need a regular expression for

Re: Regular expression question...

2006-02-12 Thread Chas Owens
On 2/12/06, Ley, Chung <[EMAIL PROTECTED]> wrote: > Hi, > > What is the regular expression to look for "%" unless that the "\" is right > before that? > > So, if I have something like this: > "\%abc%", I like to get the 2nd "%" and not the first > > Thanks... > > --Chung Your first resource f

Re: regular expression question

2005-01-17 Thread Chris Devers
On Mon, 17 Jan 2005, Vincent wrote: > I am new to perl, I receive some spam email with subject like "st0ck, > 0pportunities, gr0wth...", how can I match those words with number "0" > in You don't. I spent a about a year doing pretty much what you're asking for here, though with Procmail rules

Re: regular expression question

2005-01-17 Thread Stone
On Mon, 17 Jan 2005 16:04:48 -0500, Dave Gray <[EMAIL PROTECTED]> wrote: > > I am new to perl, I receive some spam email with subject like "st0ck, > > 0pportunities, gr0wth...", how can I match those words with number "0" in What about something like this: if ( $subject =~ /(^0[a-zA-Z]+)|([a-zA-Z

Re: regular expression question

2005-01-17 Thread Dave Gray
> I am new to perl, I receive some spam email with subject like "st0ck, > 0pportunities, gr0wth...", how can I match those words with number "0" in Something like __CODE__ use warnings; use strict; use Data::Dumper; # add to this hash to make it slower my %rep = ( 'a' => [4], 'e' => [3], '

Re: regular expression question

2004-07-02 Thread Gunnar Hjalmarsson
Graeme McLaren wrote: Afternoon all, I'm trying to to a regular expression to search and replace + with \+ I need to escape the + because it is getting used as an operator instead of a literal string, this is what I have so far: $terms[$i] =~ s/\+ /\ \\\+/g; Basically the result of searching for c+

RE: Regular expression question: non-greedy matches

2004-04-21 Thread Boris Shor
'Stuart > V. Jordan' > Subject: Re: Regular expression question: non-greedy matches > > > That is a bit off. I think we really need a sample of actual > data to be able to help you. If the data is of a > confidential nature, then you will have to do meaningful

Re: Regular expression question: non-greedy matches

2004-04-05 Thread R. Joseph Newton
Boris Shor wrote: > Thanks for writing. Hi Boris, Please don't top-post. It makes it very difficult to get the context of your message. Istead, post following the material to which you are responding. > Your code works for this example but doesn't get exactly > what I need. It's important to

RE: Regular expression question: non-greedy matches

2004-04-05 Thread Boris Shor
this, I get no matches on the 'nays' or $2. -Original Message- From: Randy W. Sims [mailto:[EMAIL PROTECTED] Sent: Sunday, April 04, 2004 9:30 PM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Re: Regular expression question: non-greedy matches Boris Shor wrote: > H

Re: Regular expression question: non-greedy matches

2004-04-04 Thread R. Joseph Newton
Boris Shor wrote: > Hello, > > Perl beginner here. I am having difficulty with a regular expression > that uses non-greedy matches. Here is a sample code snippet: > > $test = "Yea 123xrandomYea 456xdumdumNay 789xpop"; > while ($test =~ /Yea (.*?)x.*?(?:Nay (.*?)x)?/g) You have your non-capturing

Re: Regular expression question: non-greedy matches

2004-04-04 Thread Randy W. Sims
Boris Shor wrote: Hello, Perl beginner here. I am having difficulty with a regular expression that uses non-greedy matches. Here is a sample code snippet: $test = "Yea 123xrandomYea 456xdumdumNay 789xpop"; while ($test =~ /Yea (.*?)x.*?(?:Nay (.*?)x)?/g) { print "$1\n"; print "

Re: Regular Expression question

2003-10-09 Thread James Edward Gray II
On Thursday, October 9, 2003, at 03:43 PM, Dan Muey wrote: I wrote this s/([A-Za-z]*)/\n$1/g; Try this: s/\W//g; That looks like a capital W to me, though your explanation used the correct w. \W matches any NON-word character and thus wouldn't work here. James -- To unsubscribe, e-mail: [E

RE: Regular Expression question

2003-10-09 Thread Hanson, Rob
Like Jeff said, you can just use \w if you are allowing numbers as well. > s/([A-Za-z]_*)/\n$1/g; This will take a little bit of explaining, so bear with me. [ ... ] - Brackets represent a "character class". A char class will match a SINGLE char that is inside of it. So if I wanted to match "a

RE: Regular Expression question

2003-10-09 Thread Dan Muey
> I wrote this > > > s/([A-Za-z]*)/\n$1/g; Try this: s/\W//g; \w matches letters number and underscores \W matches anythgiin not letters numbers or underscores. Take a look at tr also it may be able to help you out. HTH Dmuey > > > It only gets the letters, but I am not sure how to wr

Re: Regular Expression question

2003-10-09 Thread Jeff Westman
Trina Espinoza <[EMAIL PROTECTED]> wrote: > How do you create a regular expression that allows you to have files like > ths: > Stuff_Dev > Greg_Files > myThings_ > _default > > I wrote this > > s/([A-Za-z]*)/\n$1/g; Your expression above only asked to get the letters :) You specified a chara