Re: Regexp under PERL

2015-07-08 Thread Kent Fredric
On 8 July 2015 at 19:12, Nagy Tamas (TVI-GmbH) wrote: > This is the code: > > } elsif (defined($row) && ($row =~ m/\(\*[ ]+\"\@PATH\"[ ]+:=[ > ]+'(\/)?([\*A-Za-z_ ]*(\/)?)+'[ ]\*\)?/)) { > # PATH first version: \(\*[ ]+@PATH[ ]+:=[ ]+'(\\/)?([\*A-Za-z_ > ]*(\\/)?)+'[ ]\*\)? > > my @

Re: Regexp under PERL

2015-07-07 Thread Kent Fredric
On 8 July 2015 at 04:40, Nagy Tamas (TVI-GmbH) wrote: > m/\(\*[ ]+\"\@PATH\"[ ]+:=[ ]+'(\/)?([\*A-Za-z_ ]*(\/)?)+'[ ]\*\)?/)) This is not the exact code you 're using obviously, because the last 2 ")" marks are actually outside the regex. Removing those ))'s makes the regex compile just fine. S

Re: regexp puzzle

2014-03-08 Thread Bill McCormick
On 3/8/2014 12:05 AM, Bill McCormick wrote: I have the following string I want to extract from: my $str = "foo (3 bar): baz"; and I want to to extract to end up with $p1 = "foo"; $p2 = 3; $p3 = "baz"; the complication is that the \s(\d\s.+) is optional, so in then $p2 may not be set. getting

Re: RegExp

2014-03-08 Thread Jim Gibson
On Mar 8, 2014, at 4:50 AM, rakesh sharma wrote: > Hi all, > > how do you get all words starting with letter 'r' in a string. Try my @rwords = $string =~ /\br\w*?\b/g; -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http:/

Re: RegExp

2014-03-08 Thread Janek Schleicher
Am 08.03.2014 13:50, schrieb rakesh sharma: how do you get all words starting with letter 'r' in a string. What have you tried so far? Greetings, Janek -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: RegExp

2014-03-08 Thread Shlomi Fish
Hello Rakesh, On Sat, 8 Mar 2014 18:20:48 +0530 rakesh sharma wrote: > Hi all, > how do you get all words starting with letter 'r' in a string. > thanks,rakesh > 1. Find all words in the sentence. Your idea of what is a word will need to be specified. 2

Re: RegExp

2014-03-08 Thread Shawn H Corey
On Sat, 8 Mar 2014 18:20:48 +0530 rakesh sharma wrote: > Hi all, > how do you get all words starting with letter 'r' in a string. > thanks,rakesh > /\br/ -- Don't stop where the ink does. Shawn -- To unsubscribe, e-mail: beginners-unsubscr...

Re: regexp puzzle

2014-03-07 Thread Jim Gibson
On Mar 7, 2014, at 10:05 PM, Bill McCormick wrote: > I have the following string I want to extract from: > > my $str = "foo (3 bar): baz"; > > and I want to to extract to end up with > > $p1 = "foo"; > $p2 = 3; > $p3 = "baz"; > > the complication is that the \s(\d\s.+) is optional, so in the

Re: regexp puzzle

2014-03-07 Thread shawn wilson
On Mar 8, 2014 1:41 AM, "shawn wilson" wrote: > Oh and per optional, just do (?:\([0-9]+).*\)? You should probably use do my @match = $str =~ / ([^]+) (?:\([0-9]+).*\)? ([a-z]+)/; my ($a, $b, $c) = (scalar(@match) == 3 ? @match : $match[0], undef, $match[1]); > ([^]+) \(([0-9]+).*\) ([a-z]+) >

Re: regexp puzzle

2014-03-07 Thread Bill McCormick
On 3/8/2014 12:41 AM, shawn wilson wrote: my $str = "foo (3 bar): baz"; my $test = "foo (3 bar): baz"; my ($p1, $p2, $p3) = $test =~ /([^]+) \(([0-9]+).*\) ([a-z]+)/; print "p1=[$p1] p2=[$p2] p3=[$p3]\n"; Use of uninitialized value $p1 in concatenation (.) or string at ./lock_report.pl line 1

Re: regexp puzzle

2014-03-07 Thread shawn wilson
([^]+) \(([0-9]+).*\) ([a-z]+) On Mar 8, 2014 1:07 AM, "Bill McCormick" wrote: > I have the following string I want to extract from: > > my $str = "foo (3 bar): baz"; > > and I want to to extract to end up with > > $p1 = "foo"; > $p2 = 3; > $p3 = "baz"; > > the complication is that the \s(\d\s.+)

Re: regexp as hash value?

2014-01-25 Thread Paul Johnson
On Sat, Jan 25, 2014 at 06:41:00PM +0100, Luca Ferrari wrote: > On Sat, Jan 25, 2014 at 4:12 PM, Paul Johnson wrote: > > > $ perl -E '$h = { a => qr/y/ }; say $_ =~ $h->{a} for qw(x y z)' > > Thanks, but then another doubt: having a look at > http://perldoc.perl.org/perlop.html#Regexp-Quote-Like

Re: regexp as hash value?

2014-01-25 Thread Luca Ferrari
On Sat, Jan 25, 2014 at 4:12 PM, Paul Johnson wrote: > $ perl -E '$h = { a => qr/y/ }; say $_ =~ $h->{a} for qw(x y z)' Thanks, but then another doubt: having a look at http://perldoc.perl.org/perlop.html#Regexp-Quote-Like-Operators I dont understand how I can use the regexp for substitution, th

Re: regexp as hash value?

2014-01-25 Thread Paul Johnson
On Sat, Jan 25, 2014 at 03:51:53PM +0100, Luca Ferrari wrote: > Hi, > I'm just wondering if it is possible to place a regexp as a value into > an hash so to use it later as something like: > > my $string =~ $hash_ref->{ $key }; > > Is it possible? Should I take into account something special? Ye

Re: regexp and parsing assistance

2013-06-09 Thread Noah
On 6/9/13 9:00 AM, Jim Gibson wrote: On Jun 8, 2013, at 8:06 PM, Noah wrote: Hi there, I am attempting to parse the following output and not quite sure how to do it. The text is in columns and spaced out that way regardless if there are 0 numbers in say col5 or Col 6 or not. If the colum

Re: regexp and parsing assistance

2013-06-09 Thread Jim Gibson
On Jun 8, 2013, at 8:06 PM, Noah wrote: > Hi there, > > I am attempting to parse the following output and not quite sure how to do > it. The text is in columns and spaced out that way regardless if there are > 0 numbers in say col5 or Col 6 or not. If the column has an entry then I > want

Re: regexp validation (arbitrary code execution) (regexp injection)

2011-06-02 Thread Paul Johnson
On Wed, Jun 01, 2011 at 11:25:39PM +0200, Stanisław Findeisen wrote: > Suppose you have a collection of books, and want to provide your users > with the ability to search the book title, author or content using > regular expressions. > > But you don't want to let them execute any code. > > How wo

Re: regexp validation (arbitrary code execution) (regexp injection)

2011-06-02 Thread Randal L. Schwartz
> "Stanisław" == Stanisław Findeisen writes: Stanisław> But you don't want to let them execute any code. Unless "use re 'eval'" is in scope, /$a/ is safe even if $a came from an untrusted source, as long as you limit the run-time to a few seconds or so with an alarm. (Some regex can take ne

Re: regexp validation (arbitrary code execution) (regexp injection)

2011-06-02 Thread Rob Coops
2011/6/1 Stanisław Findeisen > Suppose you have a collection of books, and want to provide your users > with the ability to search the book title, author or content using > regular expressions. > > But you don't want to let them execute any code. > > How would you validate/compile/evaluate the us

Re: regexp validation (arbitrary code execution) (regexp injection)

2011-06-02 Thread Stanisław Findeisen
On 2011-06-02 14:27, Bob McConnell wrote: > From: Stanislaw Findeisen > >> Suppose you have a collection of books, and want to provide your users >> with the ability to search the book title, author or content using >> regular expressions. >> >> But you don't want to let them execute any code. >>

RE: regexp validation (arbitrary code execution) (regexp injection)

2011-06-02 Thread Bob McConnell
From: Stanislaw Findeisen > Suppose you have a collection of books, and want to provide your users > with the ability to search the book title, author or content using > regular expressions. > > But you don't want to let them execute any code. > > How would you validate/compile/evaluate the user

Re: regexp matching nummeric ranges

2010-12-13 Thread Randal L. Schwartz
> ""Kammen" == "Kammen van, Marco, Springer SBM NL" > writes: Kammen> What am I doing wrong?? Using a regex when something else would be much better. Stop trying to pound a nail in with a wrench handle. -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 h

Re: Regexp delimiters

2010-12-08 Thread Jonathan Pool
> c:\>perl -wE "say $^V,$^O;$_='123456789';s§3(456)7§$1§;say" > v5.12.1MSWin32 > 1245689 My equivalent that works is: perl -wE "use utf8;my \$_='123456789';s§3(456)7§§\$1§;say;" 1245689 If I stop treating this section-sign delimiter as a bracketing delimiter, it fails: perl -wE "use utf8;m

Re: Regexp delimiters

2010-12-08 Thread Jonathan Pool
> Hm, what platform and perl version? 5.8.8 and 5.12.2 on RHEL, and 5.10.0 on OS X 10.6. > c:\>perl -Mutf8 -wE >"say $^V,$^O;$_='123456789';s§3(456)7§$1§;say" > Malformed UTF-8 character (unexpected continuation byte 0xa7, > with no preceding start byte) at -e line 1. Not the same err

Re: Regexp delimiters

2010-12-08 Thread C.DeRykus
On Dec 7, 9:38 am, p...@utilika.org (Jonathan Pool) wrote: > > Well, I have no idea why it does what it does, but I can tell you how to > > make it work: > > s¶3(456)7¶¶$1¶x; > > s§3(456)7§§$1§x; > Oops, sorry, yes there is: c:\>perl -Mutf8 -wE "say $^V,$^O;$_='123456789';s§3(456)7§$1§;say"

Re: Regexp delimiters

2010-12-08 Thread C.DeRykus
On Dec 7, 9:38 am, p...@utilika.org (Jonathan Pool) wrote: > > Well, I have no idea why it does what it does, but I can tell you how to > > make it work: > > s¶3(456)7¶¶$1¶x; > > s§3(456)7§§$1§x; Oops. yes there is: c:\>perl -Mutf8 -wE "say $^V,$^O;$_='123456789'; s§3(456)7§$1§;say" Malform

Re: Regexp delimiters

2010-12-08 Thread C.DeRykus
On Dec 7, 9:38 am, p...@utilika.org (Jonathan Pool) wrote: > > Well, I have no idea why it does what it does, but I can tell you how to > > make it work: > > s¶3(456)7¶¶$1¶x; > > s§3(456)7§§$1§x; > Hm, what platform and perl version? No errors here: c:\>perl -wE "say $^V,$^O;$_='1234567

Re: Regexp delimiters

2010-12-07 Thread Jonathan Pool
> Well, I have no idea why it does what it does, but I can tell you how to make > it work: > s¶3(456)7¶¶$1¶x; > s§3(456)7§§$1§x; Amazing. Thanks very much. This seems to contradict the documentation. The perlop man page clearly says that there are exactly 4 bracketing delimiters: "()", "[]", "{

Re: Regexp delimiters

2010-12-05 Thread Brian Fraser
That's probably because you are using what I sent, rather than what the OP did: > C:\>perl -E "s§3(456)7§$1§;" > Unrecognized character \x98 in column 16 at -e line 1. > > C:\>perl -Mutf8 -E "s§3(456)7§$1§;" > Substitution replacement not terminated at -e line 1. > > C:\>perl -E "s§3(456)7§§$1§;

Re: Regexp delimiters

2010-12-05 Thread Shawn H Corey
On 10-12-05 07:38 PM, Brian Fraser wrote: You have to tell perl to use UTF-8. Add this line to the top of your script(s): use utf8; See `perldoc utf8` for more details. Hm, I don't mean to step on your toes or anything, but he is already using utf8. The problem is with some utf

Re: Regexp delimiters

2010-12-05 Thread Brian Fraser
> > You have to tell perl to use UTF-8. Add this line to the top of your > script(s): > use utf8; > > See `perldoc utf8` for more details. Hm, I don't mean to step on your toes or anything, but he is already using utf8. The problem is with some utf8 characters being interpreted as a paired delimi

Re: Regexp delimiters

2010-12-05 Thread Shawn H Corey
On 10-12-05 05:58 PM, Brian Fraser wrote: Well, I have no idea why it does what it does, but I can tell you how to make it work: s¶3(456)7¶¶$1¶x; s§3(456)7§§$1§x; For whatever reason, Perl is treating those character as an 'opening' delimiter[0], so that when you write s¶3(456)7¶$1¶;, you are te

Re: Regexp delimiters

2010-12-05 Thread Brian Fraser
Well, I have no idea why it does what it does, but I can tell you how to make it work: s¶3(456)7¶¶$1¶x; s§3(456)7§§$1§x; For whatever reason, Perl is treating those character as an 'opening' delimiter[0], so that when you write s¶3(456)7¶$1¶;, you are telling Perl that the regex part is delimited

Re: regexp matching nummeric ranges

2010-11-30 Thread Rob Dixon
On 30/11/2010 06:39, Uri Guttman wrote: "GK" == Guruprasad Kulkarni writes: GK> Here is another way to do it: GK> /^127\.0\.0\.([\d]|[1-9][\d]|[1][\d][\d]|[2]([0-4][\d]|[5][0-4]))$/) { why are you putting single chars inside a char class? [\d] is the same as \d and [1] is just 1. A

Re: regexp matching nummeric ranges

2010-11-29 Thread John W. Krahn
Rob Dixon wrote: On 29/11/2010 23:46, John W. Krahn wrote: As Rob said [2..254] is a character class that matches one character (so "127.0.0.230" should match also.) You also don't anchor the pattern so something like '765127.0.0.273646' would match as well. What you need is something like thi

Re: regexp matching nummeric ranges

2010-11-29 Thread Uri Guttman
> "GK" == Guruprasad Kulkarni writes: GK> Here is another way to do it: GK> /^127\.0\.0\.([\d]|[1-9][\d]|[1][\d][\d]|[2]([0-4][\d]|[5][0-4]))$/) { why are you putting single chars inside a char class? [\d] is the same as \d and [1] is just 1. also please don't quote entire emails below

RE: regexp matching nummeric ranges

2010-11-29 Thread Kammen van, Marco, Springer SBM NL
>-Original Message- >From: John W. Krahn [mailto:jwkr...@shaw.ca] >Sent: Tuesday, November 30, 2010 12:47 AM >To: Perl Beginners >Subject: Re: regexp matching nummeric ranges >As Rob said [2..254] is a character class that matches one character (so >"127.

Re: regexp matching nummeric ranges

2010-11-29 Thread Guruprasad Kulkarni
Hi Marco, Here is another way to do it: #!/usr/bin/perl use strict; use warnings; my $ip = "127.0.0.1"; if ($ip =~ /^127\.0\.0\.([\d]|[1-9][\d]|[1][\d][\d]|[2]([0-4][\d]|[5][0-4]))$/) { print "IP Matched!\n";; } else { print "No Match!\n"; } On Tue, Nov 30, 2010 at 11:21 AM, Rob Dixon wrote:

Re: regexp matching nummeric ranges

2010-11-29 Thread Rob Dixon
On 29/11/2010 23:46, John W. Krahn wrote: Kammen van, Marco, Springer SBM NL wrote: Dear List, Hello, I've been struggeling with the following: #!/usr/bin/perl use strict; use warnings; my $ip = ("127.0.0.255"); if ($ip =~ /127\.0\.0\.[2..254]/) { print "IP Matched!\n";; } else { print "

Re: regexp matching nummeric ranges

2010-11-29 Thread John W. Krahn
Kammen van, Marco, Springer SBM NL wrote: Dear List, Hello, I've been struggeling with the following: #!/usr/bin/perl use strict; use warnings; my $ip = ("127.0.0.255"); if ($ip =~ /127\.0\.0\.[2..254]/) { print "IP Matched!\n";; } else { print "No Match!\n"; } For a reason i don't

Re: regexp matching nummeric ranges

2010-11-29 Thread Rob Dixon
On 29/11/2010 14:22, Kammen van, Marco, Springer SBM NL wrote: Dear List, I've been struggeling with the following: #!/usr/bin/perl use strict; use warnings; my $ip = ("127.0.0.255"); if ($ip =~ /127\.0\.0\.[2..254]/) { print "IP Matched!\n";; } else { print "No Match!\n"; } For a rea

Re: Regexp to remove spaces

2009-12-29 Thread Dr.Ruud
sftriman wrote: Dr.Ruud: sub trim { ... }#trim You're missing the tr to squash space down To trim() is to remove from head and tail only. Just use it as an example to build a "trim_and_normalize()". So I think it can boil down to: sub fixsp7 { s#\A\s+##, s#\s+\z##, tr/ \t\n\r\f/ /

Re: Regexp to remove spaces

2009-12-28 Thread Shawn H Corey
sftriman wrote: > So I think it can boil down to: > > sub fixsp7 { > s#\A\s+##, s#\s+\z##, tr/ \t\n\r\f/ /s foreach @_; > return; > } sub fixsp7 { tr/ \t\n\r\f/ /s, s#\A\s##, s#\s\z## foreach @_; return; } Placing the tr/// first reduces the number of characters scanned for s#\s\z## which m

Re: Regexp to remove spaces

2009-12-28 Thread sftriman
On Dec 23, 2:31 am, rvtol+use...@isolution.nl (Dr.Ruud) wrote: > sftriman wrote: > > 1ST PLACE - THE WINNER:  5.0s average on 5 runs > > > # Limitation - pointer > > sub fixsp5 { > > ${$_[0]}=~tr/ \t\n\r\f/ /s; > > ${$_[0]}=~s/\A //; > > ${$_[0]}=~s/ \z//; > > } > > Just decide to change in-place,

Re: Regexp to remove spaces

2009-12-23 Thread Dr.Ruud
sftriman wrote: 1ST PLACE - THE WINNER: 5.0s average on 5 runs # Limitation - pointer sub fixsp5 { ${$_[0]}=~tr/ \t\n\r\f/ /s; ${$_[0]}=~s/\A //; ${$_[0]}=~s/ \z//; } Just decide to change in-place, based on the defined-ness of wantarray. sub trim { no warnings 'uninitialized'; if

Re: Regexp to remove spaces

2009-12-22 Thread sftriman
Thanks to everyone for their input! So I've tried out many of the methods, first making sure that each works as I intended it. Which is, I'm not concerned with multi-line text, just single line data. That said, I have noted that I should use \A and \z in general over ^ and $. I wrote a 176 byte

Re: Regexp to remove spaces

2009-12-21 Thread Jim Gibson
At 6:11 PM +0800 12/21/09, Albert Q wrote: 2009/12/20 Dr.Ruud > > For a multi-line buffer you can do it like this: perl -wle ' my $x = <<"EOT"; 123456 \t abc def \t\t\t\t\t\t\t\t *** *** *** \t EOT s/^\s+//mg, s/\s+$//mg, s/[^\S\n]+/ /g for $x; I kno

Re: Regexp to remove spaces

2009-12-21 Thread Albert Q
2009/12/20 Dr.Ruud > > sftriman wrote: > >> I use this series of regexp all over the place to clean up lines of >> text: >> >> $x=~s/^\s+//g; >> $x=~s/\s+$//g; >> $x=~s/\s+/ /g; >> >> in that order, and note the final one replace \s+ with a single space. >> > > The g-modifier on the first 2 is bog

Re: Regexp to remove spaces

2009-12-21 Thread Dr.Ruud
Shawn H Corey wrote: $text =~ tr{\t}{ }; $text =~ tr{\n}{ }; $text =~ tr{\r}{ }; $text =~ tr{\f}{ }; $text =~ tr{ }{ }s; That can be written as: tr/\t\n\r\f/ /, tr/ / /s for $text; But it doesn't remove all leading nor all trailing spaces. -- Ruud -- To unsubscribe, e-mail: beginners-uns

Re: Regexp to remove spaces

2009-12-21 Thread Dr.Ruud
sftriman wrote: I use this series of regexp all over the place to clean up lines of text: $x=~s/^\s+//g; $x=~s/\s+$//g; $x=~s/\s+/ /g; in that order, and note the final one replace \s+ with a single space. The g-modifier on the first 2 is bogus (unless you would add an m-modifier). I current

Re: Regexp to remove spaces

2009-12-20 Thread Robert Wohlfarth
On Sat, Dec 19, 2009 at 9:13 PM, sftriman wrote: > I use this series of regexp all over the place to clean up lines of > text: > > $x=~s/^\s+//g; > $x=~s/\s+$//g; > $x=~s/\s+/ /g; > > in that order, and note the final one replace \s+ with a single space. > > Basically, it's (1) remove all leading

Re: Regexp to remove spaces

2009-12-20 Thread Shawn H Corey
John W. Krahn wrote: > That can be reduced to: > > $text =~ tr/ \t\n\r\f/ /s; > > But that still doesn't remove leading and trailing whitespace so add two > more lines: > > $text =~ tr/ \t\n\r\f/ /s; > $text =~ s/\A //; > $text =~ s/ \z//; That was left as an exercise to the reader. Come now,

Re: Regexp to remove spaces

2009-12-20 Thread John W. Krahn
Shawn H Corey wrote: sftriman wrote: I use this series of regexp all over the place to clean up lines of text: $x=~s/^\s+//g; $x=~s/\s+$//g; $x=~s/\s+/ /g; in that order, and note the final one replace \s+ with a single space. Basically, it's (1) remove all leading space, (2) remove all trail

Re: Regexp to remove spaces

2009-12-20 Thread Shawn H Corey
sftriman wrote: > I use this series of regexp all over the place to clean up lines of > text: > > $x=~s/^\s+//g; > $x=~s/\s+$//g; > $x=~s/\s+/ /g; > > in that order, and note the final one replace \s+ with a single space. > > Basically, it's (1) remove all leading space, (2) remove all trailing

Re: Regexp to remove spaces

2009-12-20 Thread Erez Schatz
2009/12/20 sftriman : > I use this series of regexp all over the place to clean up lines of > text: > > $x=~s/^\s+//g; > $x=~s/\s+$//g; > $x=~s/\s+/ /g; > You can probably use $x=~s/^(\s+)|(\s+)$//g; But I don't think it will use any less CPU than the 3 regex option, the nature of Perl's regex en

Re: regexp question

2009-09-05 Thread John W. Krahn
Noah Garrett Wallach wrote: Okay I am having troubles finding this. in the perldoc modules. Is there a slicker way to write the following? if ($line =~ /(Blah1)(.*)/) { At this point we know that the pattern matched so $1 will contain the string "Blah1" and $2 will contain a string o

Re: regexp question

2009-09-04 Thread Chas. Owens
On Fri, Sep 4, 2009 at 23:06, Noah Garrett Wallach wrote: > > > Okay I am having troubles finding this. in the perldoc modules. > Is there a slicker way to write the following? > >        if ($line =~ /(Blah1)(.*)/) { >             $blah = $1 if $1; >             $blah2 = $2 if $2; >        } snip

Re: regexp question

2009-09-04 Thread Erez Schatz
2009/9/4 Noah Garrett Wallach : > is there any way to search for the following text?  In some cases the text > that I am search could be > > "one-two-three-" > or sometimes the text could be "one-two-" If you're looking for this specific text then a good answer was already given, but if that's an

Re: regexp question

2009-09-04 Thread Chas. Owens
On Fri, Sep 4, 2009 at 04:08, Noah Garrett Wallach wrote: > > Hi there, > > is there any way to search for the following text?  In some cases the text > that I am search could be > > "one-two-three-" > > or sometimes the text could be > > "one-two-" > > what is a nice easy why to parse the above -

Re: Regexp-Question: What is backtracking?

2009-03-12 Thread Erez Schatz
2009/3/12 Deviloper > Can somebody explain what Backtracking is? > > thanx, > B. > In a nutshell, consider the following regex: /foo((b+)ar)/ a regex engine will check every character in the string that is checked against until it reaches the first "f". When reached, it will mark the place and ch

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 without any

Re: RegExp Searching - part deux

2009-01-08 Thread Paul M
That was easier: #!/usr/bin/perl use strict; use warnings; #my $line = "1elem21elema2a 1 bad13elema2eone 1 bad 1elemb2bone 2 bad1elemc2c13elemc2btwo13elemb2etwo13elem2"; my $line = "a < bade1 < bad b1 > badcb2e2"; my $cnt = 0; my @insides = $line =~ m{ (.*?)<\/elem1> }gmsx; for my $inside (

Re: RegExp Searching within

2009-01-07 Thread Hridyesh Pant
$_ = ""; while (/<(.*?)>(.*?)<\/\1>/g) { print "tag $1 which has $2 inside\n"; } Paul M wrote: Hi: Given the following list: I want to know all the "elements" within elem1. (Note: It is seriously MALFORMED XML, that is why I am attempting to use regexp). Any ideas. I can get $1

Re: RegExp Searching within

2009-01-06 Thread Jenda Krynicky
From: mer...@stonehenge.com (Randal L. Schwartz) > > "Paul" == Paul M writes: > > Paul> Note: It is seriously > Paul> MALFORMED XML > > That's a nonsense phrase, like "somewhat pregnant". It's either XML, or > it isn't. And if it isn't, get after the vendor for spewing angle-bracketish > s

Re: RegExp Searching within

2009-01-05 Thread Randal L. Schwartz
> "Paul" == Paul M writes: Paul> Note: It is seriously Paul> MALFORMED XML That's a nonsense phrase, like "somewhat pregnant". It's either XML, or it isn't. And if it isn't, get after the vendor for spewing angle-bracketish stuff at you. -- Randal L. Schwartz - Stonehenge Consulting Serv

Re: RegExp Searching within

2009-01-05 Thread Jenda Krynicky
From: Paul M > Hi: > > Given the following list: > > > > > > > > I  want to know all the "elements" within elem1. (Note: It is > seriously MALFORMED XML, that is why I am attempting to use regexp). It's hard to say, but it might be easier to fix the XML and then use normal XML tools. Beside

Re: RegExp Searching within

2009-01-05 Thread Paul M
nt = $1;     #  unless( $element =~ m{ \A \/ }msx ){           print "$1\n";     # }     } } Any ideas... The [^<]* works to strip out "descendants text nodes" but not when < and > are present. --- On Mon, 1/5/09, Mr. Shawn H. Corey wrote: From

Re: RegExp Searching within

2009-01-05 Thread Mr. Shawn H. Corey
On Mon, 2009-01-05 at 08:17 -0800, Paul M wrote: > If it were true XML, I would say all children's Node Names. > so: > > You mean all the descendants. The children of elem1 are elema and elemb. The descendants of elem1 are elema, elemb, and elemc. #!/usr/bin/perl use strict; use warnings

Re: RegExp Searching within

2009-01-05 Thread Paul M
If it were true XML,  I would say all children's Node Names. so: --- On Mon, 1/5/09, Mr. Shawn H. Corey wrote: From: Mr. Shawn H. Corey Subject: Re: RegExp Searching within To: pjm...@yahoo.com Cc: beginners@perl.org Date: Monday, January 5, 2009, 8:10 AM On Mon, 2009-01-05 at 08:02

Re: RegExp Searching within

2009-01-05 Thread Mr. Shawn H. Corey
On Mon, 2009-01-05 at 08:02 -0800, Paul M wrote: > I want to know all the "elements" within elem1. (Note: It is > seriously MALFORMED XML, that is why I am attempting to use regexp). Do you want to know all the children or all the descendants? -- Just my 0.0002 million dollars worth, Sha

Re: regexp - end of line question

2008-11-20 Thread John W. Krahn
sftriman wrote: I have data such as: A|B|C|44 X|Y|Z|33,44 C|R|E|44,55,66 T|Q|I|88,33,44 I want to find all lines with 44 in the last field. I was trying: /[,\|]44[,\$]/ which logically is perfect - but the end of line \$ doesn't seem right. How do I write: comma or pipe followed by 44 foll

Re: Regexp: Correct braces

2008-10-06 Thread Rob Dixon
Mr. Shawn H. Corey wrote: > Rob Dixon wrote: >> >> My example wasn't a nested one. It was just an example of two incorrect brace >> matches as the OP described them. > > You make it sound like I just discovered them and haven't been using > them for the past 30 years. If you have been using state

Re: Regexp: Correct braces

2008-10-06 Thread Mr. Shawn H. Corey
On Mon, 2008-10-06 at 12:12 +0100, Rob Dixon wrote: > Mr. Shawn H. Corey wrote: > > On Fri, 2008-10-03 at 12:38 +0100, Rob Dixon wrote: > >> Mr. Shawn H. Corey wrote: > >>> > >>> Note that if these structures can be nested, you will have to use a FSA > >>> with a push-down stack. > >> > >> That wil

Re: Regexp: Correct braces

2008-10-06 Thread Rob Dixon
Mr. Shawn H. Corey wrote: > On Fri, 2008-10-03 at 12:38 +0100, Rob Dixon wrote: >> Mr. Shawn H. Corey wrote: >>> >>> Note that if these structures can be nested, you will have to use a FSA >>> with a push-down stack. >> >> That will match a line like >> >> [wrong) and (wrong] >> >> Rob >> > > No

Re: Regexp: Correct braces

2008-10-03 Thread Dr.Ruud
Vyacheslav Karamov schreef: > Hi All! > > I need to capture something in braces using regular expressions. > But I don't need to capture wrong data: > > [Some text] - correct > (Some text) - also correct > [Some text) - wrong > (Some text] - also wrong http://search.cpan.org look for Regexp::Co

Re: Regexp: Correct braces

2008-10-03 Thread Mr. Shawn H. Corey
On Fri, 2008-10-03 at 12:38 +0100, Rob Dixon wrote: > Mr. Shawn H. Corey wrote: > > Note that if these structures can be nested, you will have to use a FSA > > with a push-down stack. > > That will match a line like > > [wrong) and (wrong] > > Rob > Note that if these structures can be neste

Re: Regexp: Correct braces

2008-10-03 Thread Rob Dixon
Mr. Shawn H. Corey wrote: > On Fri, 2008-10-03 at 11:52 +0300, Vyacheslav Karamov wrote: >> Hi All! >> >> I need to capture something in braces using regular expressions. >> But I don't need to capture wrong data: >> >> [Some text] - correct >> (Some text) - also correct >> [Some text) - wrong >> (

Re: Regexp: Correct braces

2008-10-03 Thread Mr. Shawn H. Corey
On Fri, 2008-10-03 at 11:52 +0300, Vyacheslav Karamov wrote: > Hi All! > > I need to capture something in braces using regular expressions. > But I don't need to capture wrong data: > > [Some text] - correct > (Some text) - also correct > [Some text) - wrong > (Some text] - also wrong > #!/usr/

Re: Regexp: Correct braces

2008-10-03 Thread Rob Dixon
Vyacheslav Karamov wrote: > Hi All! > > I need to capture something in braces using regular expressions. > But I don't need to capture wrong data: > > [Some text] - correct > (Some text) - also correct > [Some text) - wrong > (Some text] - also wrong HTH, Rob use strict; use warnings; while

Re: Regexp: Correct braces

2008-10-03 Thread Rob Coops
On Fri, Oct 3, 2008 at 11:15 AM, Vyacheslav Karamov <[EMAIL PROTECTED]>wrote: > Rob Coops пишет: > >> Try this: >> (?:Some text not captured) >> The ?: at the beginning tels perl that even though you want it to see >> thsi whole group you would not like perl to capture the string. >> Look up pe

Re: Regexp: Correct braces

2008-10-03 Thread Vyacheslav Karamov
Rob Coops пишет: Try this: (?:Some text not captured) The ?: at the beginning tels perl that even though you want it to see thsi whole group you would not like perl to capture the string. Look up perlre (http://perldoc.perl.org/perlre.html) for some more information on this particulair to

Re: Regexp in PERL

2008-09-10 Thread anders
> > $line =~ s/" ([0-9])/"$1/g; > Thanks this solve the problem for me. Anders -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: Regexp in PERL

2008-09-10 Thread Hridyesh Pant
$string =" 234234"; $string =~ s/(\s*)(?=\d+)//g; print ("$string"); anders wrote: Hi i have som text with " and space and then a numbers eg. " 234234 I tested to write $line =~ s/\" [0-9]/[0-9]/g; I like it to change " 234 to "234 But it made "[0-9] Anyone how should i have write to tel

Re: Regexp in PERL

2008-09-09 Thread John W. Krahn
anders wrote: Hi i have som text with " and space and then a numbers eg. " 234234 I tested to write $line =~ s/\" [0-9]/[0-9]/g; I like it to change " 234 to "234 But it made "[0-9] Anyone how should i have write to tell it to find and convert corrent. $line =~ s/(?<=") +(?=[0-9])//g;

Re: Regexp in PERL

2008-09-09 Thread Jeff Pang
2008/9/10 anders <[EMAIL PROTECTED]>: > Hi i have som text with " and space and then a numbers > eg. > " 234234 > > I tested to write > $line =~ s/\" [0-9]/[0-9]/g; > > I like it to change > " 234 to "234 > If you just want to remove the space between " and numbers, try: $line =~ s/\s+//; --

Re: Regexp

2008-08-23 Thread Jim
In this case my code was actually good, the problem was with the input file whice was, I am embarressed to say, empty. > It would be good if you could explain your solution. This is a list for > teaching > Perl, not just for finding solutions to individual's problems. If you publish > your workin

Re: Regexp

2008-08-21 Thread Rob Dixon
Jim wrote: > > I have solved the problem! > > Thank you for your time. It would be good if you could explain your solution. This is a list for teaching Perl, not just for finding solutions to individual's problems. If you publish your working code it may well help someone else and you would also

Re: Regexp

2008-08-21 Thread Jim
I have solved the problem! Thank you for your time. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: Regexp

2008-08-21 Thread Dr.Ruud
Jim schreef: > Given a wordlist @WordList and a file $content, > how do I construct a regexp to search for every > word in @WordList in $content. > > I have tried the following, which does not work: > > foreach $i (@WordList) > { > print "Searching: " . $i . "\n\n"; > if($content =~ m/$i/) >

Re: regexp behin assertions ?

2008-07-03 Thread epanda
Sorry I hadn't enought time /(? Hi > > Where is a solution(s) of this thread? > > It's a litle bit weird ask for help, and don't offer a "posible solution". > > At least with a study case would be enough, don't mentioning further details. > > cheers -- To unsubscribe, e-mail: [EMAIL PROTECTED] F

Re: regexp behin assertions ?

2008-07-02 Thread obdulio santana
Hi Where is a solution(s) of this thread? It's a litle bit weird ask for help, and don't offer a "posible solution". At least with a study case would be enough, don't mentioning further details. cheers -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTEC

Re: regexp behin assertions ?

2008-07-02 Thread epanda
I can't it is confidential and I have found. Thanks a lot On 2 juil, 00:46, [EMAIL PROTECTED] (Gunnar Hjalmarsson) wrote: > epanda wrote: > > Gunnar Hjalmarsson wrote: > >> [ Please do not top-post! ] > > > > >> Maybe I'm dumb, but it's not clear to me what you want to achieve. It > >> might be

Re: regexp behin assertions ?

2008-07-01 Thread Gunnar Hjalmarsson
epanda wrote: Gunnar Hjalmarsson wrote: [ Please do not top-post! ] Maybe I'm dumb, but it's not clear to me what you want to achieve. It might be easier to help you if you showed us a few _examples_, both of strings that should match and strings that should not match. I can show you sam

Re: regexp behin assertions ?

2008-07-01 Thread epanda
I can show you sample on hotmail if you want. files can't be shown On 1 juil, 21:27, [EMAIL PROTECTED] (Gunnar Hjalmarsson) wrote: > [ Please do not top-post! ] > > > > epanda wrote: > > Gunnar Hjalmarsson wrote: > >> epanda wrote: > >>> I would like to identify in a pattern a number wich is not >

Re: regexp behin assertions ?

2008-07-01 Thread Gunnar Hjalmarsson
[ Please do not top-post! ] epanda wrote: Gunnar Hjalmarsson wrote: epanda wrote: I would like to identify in a pattern a number wich is not preceded by another numbera word or a ';' followed by ;number ~ ;\d+ I have tried this s/\d+(? You probably want t

Re: regexp behin assertions ?

2008-07-01 Thread epanda
In fact I would like my number is not preceded by aor a I have tried that but error : s/(? epanda wrote: > > I would like to identify in a pattern a number wich is not > > >         preceded by     another number    a word or a ';' > >         followed > > by       ;number > > ~      ;\d+ > >

Re: regexp behin assertions ?

2008-06-30 Thread Gunnar Hjalmarsson
epanda wrote: I would like to identify in a pattern a number wich is not preceded by another numbera word or a ';' followed by ;number ~ ;\d+ I have tried this s/\d+(? You probably want to reverse the order. /(?http://www.gunnar.cc/cgi-bin/contact.pl -

  1   2   3   4   5   6   >