Re: regex matching statements

2024-06-19 Thread Levi Elias Nystad-Johansen via beginners
Hi, Yes, they are the same. I like to use $_ only when the data comes in $_ naturally. Like in a for loop: for (qw< abc >) { if ( !/\w+\d+/ ) { print "not matched"; } } Otherwise, I have to write $_, then I prefer to name the variable something descriptive instead. Makes the code

Re: regex

2024-01-24 Thread karl
Mike: > I stand properly scolded. I didn't want to scold anyone, it seems I expressed myself wrong. Sorry for that. Regards, /Karl Hammar -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: regex

2024-01-23 Thread Mike
I stand properly scolded. Mike On 1/23/24 07:01, k...@aspodata.se wrote: Please stop using my mail address when replying, I'm on the list and don't want two copies of the same mail (it's not about you Mike). -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional

Re: regex

2024-01-23 Thread karl
Please stop using my mail address when replying, I'm on the list and don't want two copies of the same mail (it's not about you Mike). Mike > Why is my Perl not working on that command? > > $ perl -e 'exit(10) if "aaa"=~/a{,2}/;' > Unescaped left brace in regex is illegal here in regex; marked

Re: regex

2024-01-22 Thread Mike
Why is my Perl not working on that command? $ perl -e 'exit(10) if "aaa"=~/a{,2}/;' Unescaped left brace in regex is illegal here in regex; marked by <-- HERE in m/a{ <-- HERE ,2}/ at -e line 1. $ But this works: $ perl -e 'exit(10) if "aaa"=~/a{0,2}/;' $ $ echo $? 10 $ It sure surprised

Re: regex

2024-01-22 Thread armando perez pena
have a problem and you say I will solve it with regular expressions then you have two problems. Ánimos! Saludos From: Claude Brown via beginners Sent: Monday, January 22, 2024 10:49:50 PM To: k...@aspodata.se ; beginners@perl.org Subject: RE: regex Jorge

RE: regex

2024-01-22 Thread Claude Brown via beginners
Jorge, Expanding on Karl's answer (and somewhat labouring his point) consider these examples: $a =~ /Jorge/ $a =~ /^Jorge/ $a =~ /Jorge$/ $a =~ /^Jorge$/ This shows that regex providing four different capabilities: - detect "Jorge" anywhere in the string - detect "Jorge" at the start of a

Re: regex

2024-01-22 Thread Levi Elias Nystad-Johansen via beginners
I agree that this is confusing, and I think many resources describing regex in unhelpful ways is partly to blame. descriptions like "pattern that matches against a string" and similar. this implies that a regex has to match the string, but this is not the case. a regex does not have to match the

Re: regex

2024-01-22 Thread Andy Bach
Yes, the {}l RE modifier has the canonical form {a,b} where a and b are numbers and so that modifies the char before it to match from a to b times, e,g A{1,3} matches one, two or three As. If you leave out the first number, zero is presumed. Hmm, perl 5.30 % perl -E 's ay(10) if "aaa"=~/a{,2}/;'

Re: regex

2024-01-22 Thread karl
Jorge Almeida: > On Mon, 22 Jan 2024 at 13:00, wrote: > > Jorge Almeida: > > > $ perl -e 'exit(10) if "aaa"=~/a{,2}/;' ... > > {,n}Match at most n times ... > Yes, I read it (several times). I still don't understand it (I understand > what you're saying, and I trust you're right, I just

Re: regex

2024-01-22 Thread karl
Jorge Almeida: > Please help me to understand this: > $ perl -e 'exit(10) if "aaa"=~/a{,2}/;' > $ echo $? > $ 10 In man perlre, under "Regular Expressions" it says: {,n}Match at most n times So /a{,2}/ matches "", "a", and "aa" and is ignorant about what comes before and after

Re: Regex to detect natural language fragment

2021-09-14 Thread Julius Hamilton
Thanks very much. @Chankey Pathak, which of those libraries does you recommend for this task? Best regards, Julius On Tue, Sep 14, 2021 at 2:33 AM Ken Peng wrote: > Or use GPT-3 who has a free online API. > https://openai.com/blog/openai-api/ > > regards > > On Mon, Sep 13, 2021 at 11:42 PM

Re: Regex to detect natural language fragment

2021-09-13 Thread Ken Peng
Or use GPT-3 who has a free online API. https://openai.com/blog/openai-api/ regards On Mon, Sep 13, 2021 at 11:42 PM Chankey Pathak wrote: > You can look into NLP https://metacpan.org/search?q=nlp > > On Mon, 13 Sept 2021 at 21:04, Julius Hamilton < > juliushamilton...@gmail.com> wrote: > >>

Re: Regex to detect natural language fragment

2021-09-13 Thread Chankey Pathak
You can look into NLP https://metacpan.org/search?q=nlp On Mon, 13 Sept 2021 at 21:04, Julius Hamilton wrote: > Hey, > > I'm not sure if this is possible, and if it's not, I'll explore a better > way to do this. > > I would like to write a script which analyzes if a line of text is > (likely) a

Re: regex help - only one value returned

2020-12-02 Thread Jim Gibson
In your original example: print "match1='$1' '$2'\n" if ($T=~/^((mr|mrs|miss|dr|prof|sir) .{5,}?)\n/smi); print "match2='$1' '$2'\n" if ($T=~/^(mr|mrs|miss|dr|prof|sir .{5,}?)\n/smi); the interior parentheses in example one terminates the alternation, so the last string is ’sir’. In example

Re: regex help - only one value returned

2020-12-02 Thread Gary Stainburn
On 02/12/2020 13:56, Vlado Keselj wrote: Well, it seems that the first one is what you want, but you just need to use $1 and ignore $2. You do need parentheses in '(mr|mrs|miss|dr|prof|sir)' but if you do not want for them to be captured in $2, you can use: '(?:mr|mrs|miss|dr|prof|sir)'. For

Re: regex help - only one value returned

2020-12-02 Thread Vlado Keselj
Well, it seems that the first one is what you want, but you just need to use $1 and ignore $2. You do need parentheses in '(mr|mrs|miss|dr|prof|sir)' but if you do not want for them to be captured in $2, you can use: '(?:mr|mrs|miss|dr|prof|sir)'. For example: print "match3='$1' '$2'\n" if

Re: Regex for date

2018-08-25 Thread Chris Charley
"Asad" wrote in message news:cag3lskh4dphjg18c-jxmo8bcqfd+vix5tep1ytsp4_6pd6z...@mail.gmail.com... Hi All , I need a regex to match the date : Sat Aug 25 08:41:03 2018 and covert into a format :'%m/%d/%Y %H:%M:%S' Thanks, -- Asad Hasan +91 9582111698 Hello Asad, You

Re: Regex for date

2018-08-25 Thread Jim Gibson
Many Perl modules have been written to parse and manipulate dates and times. Some come with Perl; others are available at www.cpan.org. Check out the Date::Manip, Date::Parse, or DateTime modules. > On Aug 25, 2018, at 4:06 AM, Asad wrote: > > Hi All , > > I need a regex to match

Re: Regex for date

2018-08-25 Thread Asad
Thanks, I'll check them out. On Sat, Aug 25, 2018 at 4:53 PM Home Linux Info wrote: > > Hello, > > Maybe not the most beautiful regex out there, hey I'm a noob, but it does > the job right: > ([A-Z][a-z]{2}\s)|([0-9]{2}\s[0-2][0-9](:[0-5][0-9]){2}\s[0-9]{4}) > You can start from here and find a

Re: Regex for date

2018-08-25 Thread Home Linux Info
Hello, Maybe not the most beautiful regex out there, hey I'm a noob, but it does the job right: ([A-Z][a-z]{2}\s)|([0-9]{2}\s[0-2][0-9](:[0-5][0-9]){2}\s[0-9]{4}) You can start from here and find a nicer form of this regex. On 8/25/18 2:06 PM, Asad wrote: Hi All ,           I need  a regex

Re: Regex for date

2018-08-25 Thread Mike Flannigan
Really, no attempt to do it yourself? Mike On 8/25/2018 6:06 AM, beginners-digest-h...@perl.org wrote: Hi All ,           I need  a regex to match the date : Sat Aug 25 08:41:03 2018 and covert into a format :  '%m/%d/%Y %H:%M:%S' Thanks, -- Asad Hasan

Re: regex to get the rpm name version

2018-08-09 Thread Andy Bach
You can put your separators in there as literals to keep them out of captures: $ cat /tmp/ver.pl #!perl while () { if ( /([\w+-]{3,})-([.\d-]+)\./ ) { print "$1 - $2\n"; } print "$_\n"; } __END__ binutils-2.23.52.0.1-12.el7.x86_64 compat-libcap1-1.10-3.el7.x86_64

Re: regex to get the rpm name version

2018-08-09 Thread Home Linux Info
Hello, You can begin with "*[a-zA-Z_+-]{3,}[0-9]*" to get the package name, it needs a little more work for right now it gets the last dash and first digit of package version. Then you can try "*([^a-zA-Z_+-]{3,})(.\d{1,})*". The first regex gives the following result: /binutils-2//

Re: regex to get the rpm name version

2018-07-27 Thread Shlomi Fish
Hi Asad, On Fri, 27 Jul 2018 18:24:39 +0530 Asad wrote: > Hi All , > > I want to get a regex to actually get the rpm name and version for > comparison : > > > binutils-2.23.52.0.1-12.el7.x86_64", > compat-libcap1-1.10-3.el7.x86_64" > compat-libstdc++-33-3.2.3-71.el7.i686 > >

Re: regex to get the rpm name version

2018-07-27 Thread Chas. Owens
But if you have to use a regex, I suggest using the /x modifier to make it easier to read an maintain the regex: #!/usr/bin/perl use strict; use warnings; for my $s (qw/binutils-2.23.52.0.1-12.el7.x86_64 compat-libcap1-1.10-3.el7.x86_64 compat-libstdc++-33-3.2.3-71.el7.i686/) { my ($name,

RE: regex to get the rpm name version

2018-07-27 Thread Duncan Ferguson
I would suggest you change your approach and user the query mode of RPM to get your information instead of build up a regexp: rpm -qa --queryformat "%{NAME}\n" Duncs From: Asad [mailto:asad.hasan2...@gmail.com] Sent: 27 July 2018 13:55 To: beginners@perl.org Subject: regex to get the rpm

Re: regex to get the rpm name version

2018-07-27 Thread Chas. Owens
I don't think a regex is the simplest and most maintainable way to get this information. I think it is probably better to take advantage of the structure of the string to discard and find information: #!/usr/bin/perl use strict; use warnings; for my $s (qw/binutils-2.23.52.0.1-12.el7.x86_64

Re: regex matches Chinese characters

2018-07-26 Thread Shlomi Fish
Hi Lauren, On Fri, 27 Jul 2018 11:28:42 +0800 "Lauren C." wrote: > greetings, > > I was doing the log statistics stuff using perl. > There are chinese characters in log items. > I tried with regex to match them, but got no luck. > > $ perl -mstrict -le 'my $char="汉语"; print "it is chinese"

Re: regex matches Chinese characters

2018-07-26 Thread Lauren C.
oops that's perfect. thanks Shlomi. On 2018/7/27 星期五 PM 1:26, Shlomi Fish wrote: Hi Lauren, On Fri, 27 Jul 2018 11:28:42 +0800 "Lauren C." wrote: greetings, I was doing the log statistics stuff using perl. There are chinese characters in log items. I tried with regex to match them, but got

Re: Regex for date format

2018-06-29 Thread Mike Martin
Worked perfectly thanks, uri, and same technique works perfectly in postgresql regexp_replace for info On 29 June 2018 at 16:18, Mike Martin wrote: > Thanks > > > On Fri, 29 Jun 2018, 15:48 Uri Guttman, wrote: > >> On 06/29/2018 10:41 AM, Mike Martin wrote: >> >> sorry >> -mm-dd

Re: Regex for date format

2018-06-29 Thread Mike Martin
Thanks On Fri, 29 Jun 2018, 15:48 Uri Guttman, wrote: > On 06/29/2018 10:41 AM, Mike Martin wrote: > > sorry > -mm-dd hh:mm:ss.dd > eg: > 2018-01-01 12-45-10-456789 to > 2018-01-01 12:45:10.456789 > > > > please reply to the list and not to me! > > then why did you want lookbehind? this

Re: Regex for date format

2018-06-29 Thread Uri Guttman
On 06/29/2018 10:41 AM, Mike Martin wrote: sorry -mm-dd hh:mm:ss.dd eg: 2018-01-01 12-45-10-456789 to 2018-01-01 12:45:10.456789 please reply to the list and not to me! then why did you want lookbehind? this is very easy if you just grab the time parts and reassemble them as you

Re: Regex for date format

2018-06-29 Thread Uri Guttman
On 06/29/2018 09:32 AM, Mike Martin wrote: Hi I am trying to convert a string of the format 2018-01-01 16-45-21-654278 to a proper timestamp string so basically I want to replace all -  after the date part i am not sure what you are trying to do. show the after text that you want. a proper

Re: regex with HEX ascii chars

2018-04-15 Thread Mike Flannigan
Try: binmode(HANDLE) before reading the file. HANDLE is your filehandle. If that doesn't work you might want to supply the text file and a sample script. Mike On 4/12/2018 12:04 PM, beginners-digest-h...@perl.org wrote: I have a text file (created by pdftotext) that I've imported into

Re: regex with HEX ascii chars

2018-04-13 Thread John W. Krahn
On Thu, 2018-04-12 at 17:26 +0100, Gary Stainburn wrote: > I have a text file (created by  pdftotext) that I've imported into my > script. > > It contains ASCII characters 251 for crosses and 252 for ticks. ASCII defines 128 characters so those characters are not ASCII. John -- To

Re: regex with HEX ascii chars

2018-04-13 Thread Gary Stainburn
On Thursday 12 April 2018 19:53:16 Shlomi Fish wrote: > Perhaps see http://perldoc.perl.org/perlunitut.html - you may need to read > the file as binary or iso8859-1 or whatever. Also see Thanks for this Shlomi. I have looked into that before briefly when doing http gets and reading office

Re: regex with HEX ascii chars

2018-04-12 Thread Shlomi Fish
On Thu, 12 Apr 2018 17:26:57 +0100 Gary Stainburn wrote: > I have a text file (created by pdftotext) that I've imported into my script. > > It contains ASCII characters 251 for crosses and 252 for ticks. If I load > the file in gvim and do :as > > it reports

Re: regex with HEX ascii chars

2018-04-12 Thread Andy Bach
> However, when I try to seacch for it using if ($line=~/[\xfb|\xfc]/) { Note, you're mixing the character class " [ab] " with grouping alternative pipe " ( a | b ) " here > or even just if ($line=~/\xfb/) { Dunno, works here: $ perl -e '$line = "hi" . chr 251 . "ho" . chr 252 ; if

Re: Regex for matching files that don't have type extensions

2016-11-05 Thread Shawn H Corey
On Sat, 05 Nov 2016 21:30:12 + Aaron Wells wrote: > True. It could get hairy. Unicode is a pretty vast landscape, and I > think if you only want ASCII word characters to count as things that > could be in a filename, your original [A-Za-z0-9_] is your best bet. > Thanks

Re: Regex for matching files that don't have type extensions

2016-11-05 Thread Octavian Rasnita
From: Aaron Wells True. It could get hairy. Unicode is a pretty vast landscape, and I think if you only want ASCII word characters to count as things that could be in a filename, your original [A-Za-z0-9_] is your best bet. Thanks to the others for their comments. As Ken says: there are

Re: Regex for matching files that don't have type extensions

2016-11-05 Thread X Dungeness
On Sat, Nov 5, 2016 at 10:55 AM, Jovan Trujillo wrote: > Hi Aaron, >In perlre I read that \w > " > > \w[3] Match a "word" character (alphanumeric plus "_", plus > other connector punctuation chars plus > Unicode >

Re: Regex for matching files that don't have type extensions

2016-11-05 Thread Aaron Wells
True. It could get hairy. Unicode is a pretty vast landscape, and I think if you only want ASCII word characters to count as things that could be in a filename, your original [A-Za-z0-9_] is your best bet. Thanks to the others for their comments. As Ken says: there are probably more ways to code

Re: Regex for matching files that don't have type extensions

2016-11-05 Thread Kent Fredric
On 6 November 2016 at 06:14, Jovan Trujillo wrote: > > 1207003PE_GM_09TNPLM2.csv > > I originally though m/[A-Za-z0-9\_]+/ would work, but it captures both > strings. > So then I tried m/[A-Za-z0-9\_]+(?!\.)/ but I still get both strings > captured. Alternatively, if

Re: Regex for matching files that don't have type extensions

2016-11-05 Thread Ken Slater
Hi Jovan, On Sat, Nov 5, 2016 at 1:14 PM, Jovan Trujillo wrote: > Hi All, > I thought I could use a simple regex to match files like this: > > 1207003PE_GM_09TNPLM2 > > and ignore files with extensions like this: > > 1207003PE_GM_09TNPLM2.csv > > I originally

Re: Regex for matching files that don't have type extensions

2016-11-05 Thread Jovan Trujillo
Hi Aaron, In perlre I read that \w " - \w[3] Match a "word" character (alphanumeric plus "_", plus - other connector punctuation chars plus Unicode - marks) " So since I didn't know what these 'other'

Re: Regex for matching files that don't have type extensions

2016-11-05 Thread Aaron Wells
*predefined On Sat, Nov 5, 2016, 10:27 AM Aaron Wells wrote: > Hi Jovan. \w is a presidents character classes that is equivalent to > [A-Za-z0-9_], so this works also: > m/^\w+$/ > > On Sat, Nov 5, 2016, 10:24 AM Jovan Trujillo > wrote: > > Ah,

Re: Regex for matching files that don't have type extensions

2016-11-05 Thread Aaron Wells
Hi Jovan. \w is a presidents character classes that is equivalent to [A-Za-z0-9_], so this works also: m/^\w+$/ On Sat, Nov 5, 2016, 10:24 AM Jovan Trujillo wrote: > Ah, I figured it out. > m/^[A-Za-z0-9_]+$/ works because it will only match if the entire string >

Re: Regex for matching files that don't have type extensions

2016-11-05 Thread Jovan Trujillo
Ah, I figured it out. m/^[A-Za-z0-9_]+$/ works because it will only match if the entire string follows the pattern. Thanks! On Sat, Nov 5, 2016 at 10:14 AM, Jovan Trujillo wrote: > Hi All, > I thought I could use a simple regex to match files like this: > >

Re: Regex to match "bad" characters in a parameter

2016-01-27 Thread lee
"Chris Charley" writes: > You could do that in 1 line - See the following small program. > (The line using a 'grep' solution is commented out. It would work as well). > > > #!/usr/bin/perl > use strict; > use warnings; > > while (my $id = ) { >chomp $id; >#if (grep

Re: Regex to match "bad" characters in a parameter

2016-01-26 Thread SSC_perl
On Jan 25, 2016, at 4:59 PM, Shawn H Corey wrote: > > Use the negative match operator !~ > > if( $QUERY_STRING !~ m{ itemid = [-0-9A-Za-z_]+? (?: \& | \z ) }msx ){ >print "bad: $QUERY_STRING\n"; > } Thanks for that, Shawn. It works perfectly except for one criteria that I

Re: Regex to match "bad" characters in a parameter

2016-01-26 Thread Chris Charley
"SSC_perl" wrote in message news:ef7499af-b4a5-4b07-8c69-3192ef782...@surfshopcart.com... On Jan 25, 2016, at 4:59 PM, Shawn H Corey wrote: Use the negative match operator !~ if( $QUERY_STRING !~ m{ itemid = [-0-9A-Za-z_]+? (?: \& | \z ) }msx ){ print "bad: $QUERY_STRING\n"; }

Re: Regex to match "bad" characters in a parameter

2016-01-26 Thread SSC_perl
On Jan 26, 2016, at 11:22 AM, Chris Charley wrote: > > You could do that in 1 line - See the following small program. Thanks, Chris. That'll do the trick. And the grep alternative is interesting, too. I hadn't thought of that. Regards, Frank -- To unsubscribe, e-mail:

Re: Regex to match "bad" characters in a parameter

2016-01-25 Thread Shawn H Corey
On Mon, 25 Jan 2016 16:16:40 -0800 SSC_perl wrote: > I'm trying to find a way to trap bad item numbers. I want to > parse the parameter "itemid=" and then everything up to either an "&" > or end-of-string. A good item number will contain only ASCII > letters,

Re: regex problem?

2015-11-25 Thread Andrew Solomon
The only problem I can see is that you want UPPERCASE-1234 and your regex has lowercase. Try (\A[A-Z]+) # match and capture leading alphabetics Andrew p.s Why not add "use strict; use warnings", "my $var;" and wear a seat belt when you're driving?:) On Wed, Nov 25, 2015 at 5:09 PM, Rick T

Re: regex problem?

2015-11-25 Thread Shawn H Corey
On Wed, 25 Nov 2015 17:22:04 + Andrew Solomon wrote: > The only problem I can see is that you want UPPERCASE-1234 and your > regex has lowercase. Try > > (\A[A-Z]+) # match and capture leading alphabetics Please put the anchor outside the capture. And you could use

Re: regex capture question

2015-06-18 Thread Илья Рассадин
Hi, Tiago! I can't reproduce such behaviour use Modern::Perl '2014'; my $string = 'Crosses misses=50 '; my (@matches) = ($string =~ /(Crosses)(.*)(misses=)(\d+)/s); use Data::Dumper; print Dumper \@matches; result: $VAR1 = [ 'Crosses', ' ',

Re: regex capture question

2015-06-18 Thread Shlomi Fish
Hi Tiago, Please reply to list if it's a mailing list post - http://shlom.in/reply . On Thu, 18 Jun 2015 10:20:57 -0300 Tiago Hori tiago.h...@gmail.com wrote: Folks, I have the following regex: $_ =~ /(Crosses)(.*)(misses=)(\d+)/s It does what I need to do in terms of matching, but I

Re: regex and parse

2014-03-11 Thread Paolo Gianrossi
A classic is Mastering Regular Expressions ny Jeffrey E.F. Friedl ( http://shop.oreilly.com/product/9781565922570.do) A quick google search also brings out, e.g. http://stackoverflow.com/questions/4736/learning-regular-expressions with many links to resources. HTH paolo -- Paolo Gianrossi Like

Re: regex and parse

2014-03-11 Thread Rob Dixon
On 11/03/2014 17:01, Ariel Hosid wrote: Can anyone recommend me literature that treats regular expressions and how to analyze files? The best documentation on regular expressions is Perl's own here http://perldoc.perl.org/perlre.html Analysing files is an enormous subject that is

Re: regex and parse

2014-03-11 Thread Charles DeRykus
On Tue, Mar 11, 2014 at 10:01 AM, Ariel Hosid ariel.ho...@gmail.com wrote: Hello everyone! Can anyone recommend me literature that treats regular expressions and how to analyze files? Some perl resources: perldoc perlrequick(Perl regular expressions quick start) perlretut

Re: regex and parse

2014-03-11 Thread Andy Bach
On Tue, Mar 11, 2014 at 12:13 PM, Paolo Gianrossi paolino.gianro...@gmail.com wrote: A classic is Mastering Regular Expressions ny Jeffrey E.F. Friedl ( http://shop.oreilly.com/product/9781565922570.do) Just to +1 this - one of the best RE and programming books ever - it's not just Perl REs

Re: regex and parse

2014-03-11 Thread Ariel Hosid
OK! Thanks to all! :-) 2014-03-11 15:34 GMT-03:00 Andy Bach afb...@gmail.com: On Tue, Mar 11, 2014 at 12:13 PM, Paolo Gianrossi paolino.gianro...@gmail.com wrote: A classic is Mastering Regular Expressions ny Jeffrey E.F. Friedl ( http://shop.oreilly.com/product/9781565922570.do) Just

Re: regex to get version from file name

2014-02-23 Thread Wernher Eksteen
Hi, Thanks, but how do I assign the value found by the regex to a variable so that the 1.2.4 from 6 file names in the array @fileList are print only once, and if there are other versions found say 1.2.5 and 1.2.6 to print the unique values from all. This is my script thus far. The aim of this

Re: regex to get version from file name

2014-02-23 Thread shawn wilson
Use LWP to get web data - not lynx and the like unless you can't help it. I prefer using Web::Scraper to parse html but either way it's probably best not to use a regex (see SO and similar for discussions on the like). On Feb 23, 2014 8:13 AM, Wernher Eksteen crypt...@gmail.com wrote: Hi,

Re: regex to get version from file name

2014-02-23 Thread Wernher Eksteen
Thanks, I've changed it to use LWP. I'm not sure how to download the actual file with LWP, so I've tried File::Fetch which works, but it doesn't show download progress/status etc, just hanging blank until the download completes. Any pointers on getting download status/progress details? foreach

Re: regex to get version from file name

2014-02-23 Thread Jim Gibson
On Feb 21, 2014, at 6:21 AM, Wernher Eksteen crypt...@gmail.com wrote: Hi all, From the below file names I only need the version number 1.2.4 without explicitly specifying it. check_mk-1.2.4.tar.gz check_mk-agent-1.2.4-1.noarch.rpm check_mk-agent-logwatch-1.2.4-1.noarch.rpm

Re: regex to get version from file name

2014-02-23 Thread Jim Gibson
On Feb 23, 2014, at 5:10 AM, Wernher Eksteen crypt...@gmail.com wrote: Hi, Thanks, but how do I assign the value found by the regex to a variable so that the 1.2.4 from 6 file names in the array @fileList are print only once, and if there are other versions found say 1.2.5 and 1.2.6 to

Re: regex to get version from file name

2014-02-23 Thread Wernher Eksteen
Thanks, this also worked for me... foreach my $i (@fileList) { push @versions, $i =~ m/\b(\d+\.\d+\.\d+)\b/g; } my %seen; my @unique = grep { ! $seen{$_}++ } @versions; On Sun, Feb 23, 2014 at 4:27 PM, Jim Gibson j...@gibson.org wrote: On Feb 23, 2014, at 5:10 AM, Wernher Eksteen

Re: regex to get version from file name

2014-02-23 Thread Wernher Eksteen
Great thank you! On Fri, Feb 21, 2014 at 6:02 PM, Jim Gibson j...@gibson.org wrote: On Feb 21, 2014, at 6:21 AM, Wernher Eksteen crypt...@gmail.com wrote: Hi all, From the below file names I only need the version number 1.2.4 without explicitly specifying it.

Re: regex to get version from file name

2014-02-21 Thread Shawn H Corey
On Fri, 21 Feb 2014 16:21:57 +0200 Wernher Eksteen crypt...@gmail.com wrote: Hi all, From the below file names I only need the version number 1.2.4 without explicitly specifying it. check_mk-1.2.4.tar.gz check_mk-agent-1.2.4-1.noarch.rpm check_mk-agent-logwatch-1.2.4-1.noarch.rpm

Re: regex headache

2014-02-04 Thread Dr.Ruud
On 2014-02-03 21:30, Paul Fontenot wrote: Hi, I am attempting to write a regex but it is giving me a headache. I have two log entries 1. Feb 3 12:54:28 cdrtva01a1005 [12: 54:27,532] ERROR [org.apache.commons.logging.impl.Log4JLogger] 2. Feb 3 12:54:28 cdrtva01a1005 [12: 54:27,532] ERROR

Re: regex headache

2014-02-03 Thread Jim Gibson
On Feb 3, 2014, at 12:30 PM, Paul Fontenot wrote: Hi, I am attempting to write a regex but it is giving me a headache. I have two log entries 1. Feb 3 12:54:28 cdrtva01a1005 [12: 54:27,532] ERROR [org.apache.commons.logging.impl.Log4JLogger] 2. Feb 3 12:54:28 cdrtva01a1005 [12:

Re: Regex not working correctly

2013-12-11 Thread Shlomi Fish
Hi punit, On Wed, 11 Dec 2013 21:04:39 +0530 punit jain contactpunitj...@gmail.com wrote: Hi, I have a requirement where I need to capture phone number from different strings. The strings could be :- 1. COMP TEL NO 919369721113 for computer science 2. For Best Discount reach

Re: Regex not working correctly

2013-12-11 Thread Jim Gibson
On Dec 11, 2013, at 7:34 AM, punit jain contactpunitj...@gmail.com wrote: Hi, I have a requirement where I need to capture phone number from different strings. The strings could be :- 1. COMP TEL NO 919369721113 for computer science 2. For Best Discount reach 092108493, from

Re: Regex not working correctly

2013-12-11 Thread punit jain
Thanks Shlomi, thats a good idea. However at the same time I was trying to understand if something is wrong in my regex. Why would $2 capture the number as I have used :- (?:(91\d{10}|0\d{10}|[7-9]\d{9}|0\d{11})|(?:(?:ph|cal)(\d+))) This would in my understanding match either number with regex

RE: Regex not working correctly

2013-12-11 Thread vijaya R
Hi, You can try the below pattern. if($line=~/([0-9]{3,})/gs) { print $1; } Thanks, Vijaya -- From: punit jain Sent: 12/11/2013 9:07 PM To: beginners@perl.org Subject: Regex not working correctly Hi, I have a requirement where I need to capture phone

Re: Regex not working correctly

2013-12-11 Thread Robert Wohlfarth
On Wed, Dec 11, 2013 at 10:35 AM, punit jain contactpunitj...@gmail.comwrote: Thanks Shlomi, thats a good idea. However at the same time I was trying to understand if something is wrong in my regex. Why would $2 capture the number as I have used :-

Re: Regex not working correctly

2013-12-11 Thread punit jain
That answers my question. Thanks Robert

Re: Regex help needed

2013-01-09 Thread *Shaji Kalidasan*
Punit Jain, This is not the optimized code but you can refactor it. This works for the given scenario, no matter the order of input data. Hope it helps to some extent. [code] my $var = ''; my @args = (); my %hash; while (DATA) { chomp; my ($var,$arg) = split /=/,$_,2; if($var eq '{') { @args

Re: Regex help needed

2013-01-09 Thread Dr.Ruud
On 2013-01-08 13:28, punit jain wrote: { test = (test123); test = (test123,abc); test = (test123,abc,xyz); } { test1 = (passfile); test1 = (passfile,pasfile1); test1 = (passfile,pasfile1,user); } and so on The requirement is to have the file parsing so that final output is :- test =

Re: Regex help needed

2013-01-08 Thread Jim Gibson
On Jan 8, 2013, at 4:28 AM, punit jain wrote: Hi , I have a file as below : - { test = (test123); test = (test123,abc); test = (test123,abc,xyz); } { test1 = (passfile); test1 = (passfile,pasfile1); test1 = (passfile,pasfile1,user); } and so on The requirement is to

Re: Regex help needed

2013-01-08 Thread timothy adigun
Hi punit jain, Please check my comments below. On Tue, Jan 8, 2013 at 1:28 PM, punit jain contactpunitj...@gmail.comwrote: Hi , I have a file as below : - { test = (test123); test = (test123,abc); test = (test123,abc,xyz); } { test1 = (passfile); test1 = (passfile,pasfile1); test1

Re: Regex issue

2013-01-06 Thread midhun
Ya, this code is perfect Punit. This works fine for me too. Regards, Midhun On Thu, Jan 3, 2013 at 4:46 PM, Paul Johnson p...@pjcj.net wrote: On Thu, Jan 03, 2013 at 03:53:20PM +0530, punit jain wrote: Hi, I am facing issues in parsing using Regex. The problem definition is as below :

Re: Regex issue

2013-01-03 Thread Shlomi Fish
Hi Punit, some comments on your code: On Thu, 3 Jan 2013 15:53:20 +0530 punit jain contactpunitj...@gmail.com wrote: Hi, I am facing issues in parsing using Regex. The problem definition is as below : - A file with data :- BEGIN country Japan passcode 1123 listname sales contact

Re: Regex issue

2013-01-03 Thread Paul Johnson
On Thu, Jan 03, 2013 at 03:53:20PM +0530, punit jain wrote: Hi, I am facing issues in parsing using Regex. The problem definition is as below : - I want to parse it in such a way that all data with BEGIN and END goes in one file and BEGINDL and ENDDL goes in other with kind of processing

Re: Regex help

2012-12-22 Thread Paul Johnson
On Sat, Dec 22, 2012 at 04:45:21PM +0530, punit jain wrote: Hi, I have a file like below : - BEGIN:VCARD VERSION:2.1 EMAIL:te...@test.com FN:test1 REV:20101116T030833Z UID:644938456.1419. END:VCARD From (S___-0003) Tue Nov 16 03:10:15 2010 content-class:

Re: Regex help

2012-12-22 Thread David Precious
On Sat, 22 Dec 2012 16:45:21 +0530 punit jain contactpunitj...@gmail.com wrote: Hi, I have a file like below : - [snipped example - vcards with mail headers etc in between] My requirement is to get all text between BEGIN:VCARD and END:VCARD and all the instances. So o/p should be :-

Re: Regex help

2012-12-22 Thread Rob Dixon
On 22/12/2012 11:15, punit jain wrote: Hi, I have a file like below : - BEGIN:VCARD VERSION:2.1 EMAIL:te...@test.com FN:test1 REV:20101116T030833Z UID:644938456.1419. END:VCARD From (S___-0003) Tue Nov 16 03:10:15 2010 content-class: urn:content-classes:person Date: Tue, 16 Nov

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 sending me mad

2012-07-28 Thread Dr.Ruud
On 2012-07-27 17:43, Andy Bach wrote: On Fri, Jul 27, 2012 at 10:22 AM, Dr.Ruud rvtol+use...@isolution.nl wrote: On 2012-07-27 16:58, Andy Bach wrote: if ($model=~/(\S+)\s+(.*)\s*$/) { The \s* in the end does nothing. Well, I was thinking if it's a multi-word second match: v6 Austin

Re: Regex sending me mad

2012-07-27 Thread Jim Gibson
On Jul 27, 2012, at 7:04 AM, Gary Stainburn wrote: Hi folks. I'm struggling to see what I'm doing wrong. I have the following code in one of my programs but it isn't working as it should. print STDERR enqmake='$enqmake' model='$model'\n; if (!$enqmake $model) { # extract make

Re: Regex sending me mad

2012-07-27 Thread Shawn H Corey
On Fri, 27 Jul 2012 07:29:13 -0700 Jim Gibson jimsgib...@gmail.com wrote: Why aren't you using the split function? ($model,$engmake) = split(' ',$model); That would be: ($model,$engmake) = split(' ',$model, 2); See `perldoc -f split` for details. -- Just my 0.0002 million

Re: Regex sending me mad

2012-07-27 Thread Andy Bach
On Fri, Jul 27, 2012 at 9:04 AM, Gary Stainburn gary.stainb...@ringways.co.uk wrote: print STDERR About to split '$model'\n; if ($model=~/ *?(\w*) (.*?) *$/) { $enqmake=lc($1); $model=$2; print STDERR model split into '$enqmake' '$model'\n; } } # extract make This

Re: Regex sending me mad

2012-07-27 Thread Dr.Ruud
On 2012-07-27 16:58, Andy Bach wrote: if ($model=~/(\S+)\s+(.*)\s*$/) { The \s* in the end does nothing. Closer: /(\S+)\s+(.*\S)/ Then play with this: perl -Mstrict -we' my $data= $ARGV[0] ? q{Ford} : qq{ \t Fiat Ulysse 2.1 TD}; printf qq{%s %s\n}, split( q{ }, $data, 2 ),

SOLVED Re: Regex sending me mad

2012-07-27 Thread Gary Stainburn
On Friday 27 July 2012 15:58:07 Andy Bach wrote: Your RE is a bit odd - all that 'non-greedy *' -ness implies troubles. The first space star ? can be greedy, right? You want all the spaces/white space in a row, or rather don't want - as you're anchored on the end, this doesn't do anything

Re: Regex sending me mad

2012-07-27 Thread Andy Bach
On Fri, Jul 27, 2012 at 10:22 AM, Dr.Ruud rvtol+use...@isolution.nl wrote: On 2012-07-27 16:58, Andy Bach wrote: if ($model=~/(\S+)\s+(.*)\s*$/) { The \s* in the end does nothing. Well, I was thinking if it's a multi-word second match: v6 Austin Martinspacespace Then that would matches

Re: Regex character classes: n OR m

2012-07-06 Thread Paul Johnson
On Fri, Jul 06, 2012 at 06:59:00PM +0100, Adam J. Gamble wrote: Dear All, I'm taking a (highly belated) first look at Perl today. From a background in Python, I'm coming to Perl, primarily out of curiosity with what it can do with regular expressions. Welcome! To get to the point— is it

Re: Regex character classes: n OR m

2012-07-06 Thread Shawn H Corey
On Fri, 6 Jul 2012 18:59:00 +0100 Adam J. Gamble a.gam...@lucida.cc wrote: Dear All, I'm taking a (highly belated) first look at Perl today. From a background in Python, I'm coming to Perl, primarily out of curiosity with what it can do with regular expressions. To get to the point— is

  1   2   3   4   5   6   7   8   9   10   >