Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > fr.comp.lang.regexp > #187

Re: Extraction nombre décimaux.

From Marc SCHAEFER <schaefer@alphanet.ch>
Newsgroups fr.comp.lang.regexp
Subject Re: Extraction nombre décimaux.
Date 2022-10-23 13:25 +0000
Organization Posted through news.alphanet.ch
Message-ID <tj3fco$b2h$1@shakotay.alphanet.ch> (permalink)
References <635501d4$0$22259$426a74cc@news.free.fr>

Show all headers | View raw


kurtz le pirate <kurtzlepirate@free.fr> wrote:
>   @floatnum = $line =~ /[-+]?([0-9]*\.[0-9]+|[0-9]+)/g;

comme [-+]? n'est pas entre (), Perl ne va pas l'extraire et il ne va
pas finir dans le tableau.

@floatnum = $line =~ /([-+]?[0-9]*\.[0-9]+|[0-9]+)/g;

démo:

schaefer@reliand:/tmp$ ./a.pl 
1.2
1.2
1.2 4.5
1.2, 4.5
-1.2 
-1.2
-1.2 4.5
-1.2, 4.5

schaefer@reliand:/tmp$ cat a.pl 
#! /usr/bin/perl

use strict;
use warnings;

while (my $line = <STDIN>) {
   my @f = $line =~ /([-+]?[0-9]*\.[0-9]+|[0-9]+)/g;

   print join(', ', @f), "\n";
}

Back to fr.comp.lang.regexp | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Extraction nombre décimaux. kurtz le pirate <kurtzlepirate@free.fr> - 2022-10-23 10:56 +0200
  Re: Extraction nombre décimaux. Olivier Miakinen <om+news@miakinen.net> - 2022-10-23 11:32 +0200
    Re: Extraction nombre décimaux. Marc SCHAEFER <schaefer@alphanet.ch> - 2022-10-23 13:17 +0000
      Re: Extraction nombre décimaux. Richard Hachel <r.hachel@jesaispu.fr> - 2022-10-23 13:18 +0000
        Re: Extraction nombre décimaux. Olivier Miakinen <om+news@miakinen.net> - 2022-10-23 20:35 +0200
      Re: Extraction nombre décimaux. Olivier Miakinen <om+news@miakinen.net> - 2022-10-23 20:33 +0200
        Re: Extraction nombre décimaux. Marc SCHAEFER <schaefer@alphanet.ch> - 2022-10-24 06:52 +0000
        Re: Extraction nombre décimaux. Marc SCHAEFER <schaefer@alphanet.ch> - 2022-10-24 06:53 +0000
  Re: Extraction nombre décimaux. Marc SCHAEFER <schaefer@alphanet.ch> - 2022-10-23 13:15 +0000
    Re: Extraction nombre décimaux. kurtz le pirate <kurtzlepirate@free.fr> - 2022-10-24 17:27 +0200
      Re: Extraction nombre décimaux. Olivier Miakinen <om+news@miakinen.net> - 2022-10-24 17:57 +0200
        Re: Extraction nombre décimaux. kurtz le pirate <kurtzlepirate@free.fr> - 2022-10-25 16:58 +0200
          Re: Extraction nombre décimaux. Olivier Miakinen <om+news@miakinen.net> - 2022-10-26 15:58 +0200
  Re: Extraction nombre décimaux. Marc SCHAEFER <schaefer@alphanet.ch> - 2022-10-23 13:25 +0000

csiph-web