Re: RegExp Problem using Substitutions.

2009-02-24 Thread Rob Dixon
Deviloper wrote: > Hi there! > > I have a string "bbbababbaaassass". I want to get a string without any > double a 'aa' or and without the 'b's. > > but if I do: > > my $s = "bbbababbaaassass"; > $s=~ s/aa|b//g; > > as a result I will get a string "aaassass". > > (I understand WHY I g

Re: RegExp Problem using Substitutions.

2009-02-24 Thread John W. Krahn
John W. Krahn wrote: Deviloper wrote: Hi there! Hello, I have a string "bbbababbaaassass". I want to get a string without any double a 'aa' or and without the 'b's. but if I do: my $s = "bbbababbaaassass"; $s=~ s/aa|b//g; as a result I will get a string "aaassass". (I understand

Re: RegExp Problem using Substitutions.

2009-02-24 Thread John W. Krahn
Deviloper wrote: Hi there! Hello, I have a string "bbbababbaaassass". I want to get a string without any double a 'aa' or and without the 'b's. but if I do: my $s = "bbbababbaaassass"; $s=~ s/aa|b//g; as a result I will get a string "aaassass". (I understand WHY I get this result.

RE: RegExp Problem using Substitutions.

2009-02-24 Thread ramesh.marimuthu
Try this: $s=~s/b|ab*a//g; -Original Message- From: Deviloper [mailto:devilo...@slived.net] Sent: Tuesday, February 24, 2009 4:03 PM To: beginners@perl.org Subject: RegExp Problem using Substitutions. Hi there! I have a string "bbbababbaaassass". I want to get a string w

RegExp Problem using Substitutions.

2009-02-24 Thread Deviloper
Hi there! I have a string "bbbababbaaassass". I want to get a string without any double a 'aa' or and without the 'b's. but if I do: my $s = "bbbababbaaassass"; $s=~ s/aa|b//g; as a result I will get a string "aaassass". (I understand WHY I get this result. But I don“t know how to av

Re: regexp problem

2007-06-14 Thread Rob Dixon
Jorge Almeida wrote: I'm missing something about Perl's regexp: 1 #!/usr/bin/perl -w 2 use strict; 3 my $s=; 4 $s=~s/\D*//; 5 $s=~s/\D*//; 6 print "$s\n"; When input is 'a123b', I get '123b', but I expected '123'. I know I can substitute line 4 by '$s=~s/\D*//g;' and comment out lin

Re: regexp problem

2007-06-14 Thread Xavier Noria
On Jun 14, 2007, at 12:49 PM, Jorge Almeida wrote: Martin was right (and I should have seen it from the start). The "will go ahead as much as possible" is true only in the sense that the greatest possible string of non-digits will be selected for deletion. With '$s=~s/\D*//;' in line 5 that stri

Re: regexp problem

2007-06-14 Thread Jorge Almeida
On Thu, 14 Jun 2007, Xavier Noria wrote: On Jun 14, 2007, at 12:10 PM, Martin Barth wrote: On Thu, 14 Jun 2007 11:04:51 +0100 (WEST) Jorge Almeida <[EMAIL PROTECTED]> wrote: > I'm missing something about Perl's regexp: > >1 #!/usr/bin/perl -w >2 use strict; >3 my $s=; >4 $s=

Re: regexp problem

2007-06-14 Thread Xavier Noria
On Jun 14, 2007, at 12:10 PM, Martin Barth wrote: On Thu, 14 Jun 2007 11:04:51 +0100 (WEST) Jorge Almeida <[EMAIL PROTECTED]> wrote: I'm missing something about Perl's regexp: 1 #!/usr/bin/perl -w 2 use strict; 3 my $s=; 4 $s=~s/\D*//; 5 $s=~s/\D*//; 6 print "$s\n"; When in

Re: regexp problem

2007-06-14 Thread Jorge Almeida
On Thu, 14 Jun 2007, Martin Barth wrote: On Thu, 14 Jun 2007 11:04:51 +0100 (WEST) Jorge Almeida <[EMAIL PROTECTED]> wrote: I'm missing something about Perl's regexp: 1 #!/usr/bin/perl -w 2 use strict; 3 my $s=; 4 $s=~s/\D*//; 5 $s=~s/\D*//; 6 print "$s\n"; When input is 'a

Re: regexp problem

2007-06-14 Thread Martin Barth
On Thu, 14 Jun 2007 11:04:51 +0100 (WEST) Jorge Almeida <[EMAIL PROTECTED]> wrote: > I'm missing something about Perl's regexp: > >1 #!/usr/bin/perl -w >2 use strict; >3 my $s=; >4 $s=~s/\D*//; >5 $s=~s/\D*//; >6 print "$s\n"; > > When input is 'a123b', I get '123b', but

Re: regexp problem

2007-06-14 Thread Xavier Noria
On Jun 14, 2007, at 12:04 PM, Jorge Almeida wrote: I'm missing something about Perl's regexp: 1 #!/usr/bin/perl -w 2 use strict; 3 my $s=; 4 $s=~s/\D*//; 5 $s=~s/\D*//; 6 print "$s\n"; When input is 'a123b', I get '123b', but I expected '123'. s/\D+//g; -- fxn -- To unsubscr

regexp problem

2007-06-14 Thread Jorge Almeida
I'm missing something about Perl's regexp: 1 #!/usr/bin/perl -w 2 use strict; 3 my $s=; 4 $s=~s/\D*//; 5 $s=~s/\D*//; 6 print "$s\n"; When input is 'a123b', I get '123b', but I expected '123'. I know I can substitute line 4 by '$s=~s/\D*//g;' and comment out line 5. It will work then

Re: Regexp problem

2007-05-02 Thread Howard Sherman
Glad you got the answer. Next time, please work harder on explaining your problem so the community can understand what you want and benefit from the solution. Somu <[EMAIL PROTECTED]> wrote: I got the answer and its working fine.. Actually i made a TicTacToe game using Tk. The buttons have are

Re: Regexp problem

2007-05-02 Thread Somu
I got the answer and its working fine.. Actually i made a TicTacToe game using Tk. The buttons have are like as below: l o r m p s n q t and i keep adding the character alternatingly to 2 strings.. When any of the strings reaches length >= 3 then i start checking for any pattern out of the eight..

Re: Regexp problem

2007-05-02 Thread Rob Dixon
Somu wrote: Actually thats what i was looking for: l.*o.*r So, if the user entered string is to be matched for 'lpt', then i'll use l.*p.*t ? And to match 'npr' i use .*n.*p.*r ? Somu you need to tell us exactly what match you want, otherwise we can't tell you whether something will work or

Re: Regexp problem

2007-05-02 Thread Somu
Actually thats what i was looking for: l.*o.*r So, if the user entered string is to be matched for 'lpt', then i'll use l.*p.*t ? And to match 'npr' i use .*n.*p.*r ? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: Regexp problem

2007-05-01 Thread Tom Phoenix
On 5/1/07, Somu <[EMAIL PROTECTED]> wrote: my $input = 'loqr'; if ( $input =~ m!lor!i ) {print 'match'} how will that match? i want them to match. Thats what i want to do. You can add the 'q' to the pattern. Is this what you want? if ( $input =~ /loqr/i ) { print 'match' } Or you can

Re: Regexp problem

2007-05-01 Thread Somu
Thats where the problem arises my $input = 'loqr'; if ( $input =~ m!lor!i ) {print 'match'} how will that match? i want them to match. Thats what i want to do. by the way, can i get some url where i can get lots of problems and solutions on regexp. I'm very weak in it.. -- To unsubscribe, e-ma

Re: Regexp problem

2007-05-01 Thread Howard Sherman
#!/usr/bin/perl use strict; my @Strings = qw(lmn lpt lor mps npr nqt opq rst); chomp(my $Input = ); my $SortedChars = join "", sort (split //, $Input); foreach (@Strings) { if ($SortedChars =~ /$_/) { print "Got a match for $Input with $_\n";

Re: Regexp problem

2007-05-01 Thread Tom Phoenix
On 5/1/07, Somu <[EMAIL PROTECTED]> wrote: Hi, i have a matching problem. I get input from the user as a 3-5 character long string consisting of characters from 'l' to 't', and the chars are always sorted for example, the user enters: 'lrqo'. It becomes: 'loqr'. But i have to match the modified

Re: Regexp problem

2007-05-01 Thread Jeff Pang
2007/5/2, Somu <[EMAIL PROTECTED]>: Hi, i have a matching problem. I get input from the user as a 3-5 character long string consisting of characters from 'l' to 't', and the chars are always sorted for example, the user enters: 'lrqo'. It becomes: 'loqr'. But i have to match the modified string

Regexp problem

2007-05-01 Thread Somu
Hi, i have a matching problem. I get input from the user as a 3-5 character long string consisting of characters from 'l' to 't', and the chars are always sorted for example, the user enters: 'lrqo'. It becomes: 'loqr'. But i have to match the modified string to any of the following: lmn, lpt, lo

Re: Regexp problem

2004-09-01 Thread Gunnar Hjalmarsson
Gunnar Hjalmarsson wrote: Can it possibly be that you need to make the first regex non-greedy? /\.{4}/s --^ Or a more plausible explanation is that you are looping over the text line by line. Maybe you simply need to do: my $text = do { local $/; <> }; $text =~ s/[^\n]*\.{4}

Re: Regexp problem

2004-09-01 Thread Gunnar Hjalmarsson
Hamish Whittal wrote: (Example 1) I have the following lines: This is some text..MBAAAEgAAAQAB blaah,blaah =+=+=+=+=+=+=+=+=+=+=+ (Example 2) but sometimes it looks like this: This is some text.. MBAAAEgAAAQAoBAAAQKAREDSCETRTBDFS blaah,blaah =+=+=+=+=+=+=+=+=+=+=+ Now, given this, I am want

Regexp problem

2004-09-01 Thread Hamish Whittal
Hi all, (Example 1) I have the following lines: This is some text..MBAAAEgAAAQAB blaah,blaah =+=+=+=+=+=+=+=+=+=+=+ (Example 2) but sometimes it looks like this: This is some text.. MBAAAEgAAAQAoBAAAQKAREDSCETRTBDFS blaah,blaah =+=+=+=+=+=+=+=+=+=+=+ Now, given this, I am wanting to skip

RE: RegExp Problem...

2001-09-18 Thread Bob Showalter
> -Original Message- > From: Jeff 'japhy/Marillion' Pinyan [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, September 18, 2001 9:57 AM > To: David Simcik > Cc: Perl Beginners > Subject: Re: RegExp Problem... > > > On Sep 18, David Simcik said: > ... &g

Re: RegExp Problem...

2001-09-18 Thread Jeff 'japhy/Marillion' Pinyan
On Sep 18, David Simcik said: >sub isFacStaff >{ > my $id = @_; This is the error: assignment of an array to a scalar returns the number of elements. You want want one of the following: my $id = shift; my ($id) = @_; my $id = $_[0]; > if($id =~ m/^.+_.+$/i) You're doing to

Re: RegExp Problem...

2001-09-18 Thread Brett W. McCoy
On Tue, 18 Sep 2001, David Simcik wrote: > Hi folks, > I'm stumped...I wrote a test script and this pattern matches just fine, but > when I try to use it in another script it does match as it should. > Basically, if the pattern detects an _ underscore in the string it should > return undef;

RegExp Problem...

2001-09-18 Thread David Simcik
Hi folks, I'm stumped...I wrote a test script and this pattern matches just fine, but when I try to use it in another script it does match as it should. Basically, if the pattern detects an _ underscore in the string it should return undef; if it doesn't match it returns true. Here's some

RE: RegExp problem

2001-07-09 Thread saliminl
Thanks a ton! I've been working with "Perl, A Beginner's Guide" for a few days now and referencing the Camel. These scripts will definitely aid me greatly on the UNIX systems on which I do computational chemistry. Neema Salimi [EMAIL PROTECTED] >= Original Message From [EMAIL PROTECTED]

Re: RegExp problem

2001-07-09 Thread Jeff 'japhy' Pinyan
On Jul 9, saliminl said: >Hi. This is my first post. I'm trying to write a script that retrieves >data from a text file. The text files have several hundred instances of >the string "EAMBER (non-constraint) = #" where the # is a number that >can be negative and the last spacing after the equal

RegExp problem

2001-07-09 Thread saliminl
Hi. This is my first post. I'm trying to write a script that retrieves data from a text file. The text files have several hundred instances of the string "EAMBER (non-constraint) = #" where the # is a number that can be negative and the last spacing after the equals sign is variable. My pro