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


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

Extraction nombre décimaux.

Newsgroups fr.comp.lang.regexp
From kurtz le pirate <kurtzlepirate@free.fr>
Subject Extraction nombre décimaux.
Organization Compagnie de la Banquise
Date 2022-10-23 10:56 +0200
Message-ID <635501d4$0$22259$426a74cc@news.free.fr> (permalink)

Show all headers | View raw


Bonjour,

Je troune en rond depuis quelques temps sur l'extraction de nombre
décimaux depuis un fichiers. je n'arrive pas à capturer le signe.

Le bout de code :

my $countLine = 1;
my @floatnum;
foreach my $line (<SRCFILE>) {
  chomp $line;
  printf("%4d : %s\n", $countLine, $line);
  @floatnum = $line =~ /[-+]?([0-9]*\.[0-9]+|[0-9]+)/g;
# @floatnum = $line =~ /($RE{num}{real})/g;
# @floatnum = $line =~ /([+-]?\d+(\.\d+)?)/g;
  if (@floatnum) {
    print "float = $_\n" foreach (@floatnum);
    }
  $countLine++;
  }

Surtout (!) pour les nombres négatifs.
Le "+" pour les nombres positifs n'existe jamais.


Exemple :
#declare x = -.168452; #declare y = 0.456; #declare z = -5.4563e6;

Je récupère :
float = .168452
float = 0.456
float = 5.4563
float = 6


Pas de signe.
Faut aussi que je m'occupe des exposants mais après ...


Merci pour vos suggestions.

-- 
kurtz le pirate
compagnie de la banquise

Back to fr.comp.lang.regexp | Previous | Next — Next 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