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


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

Re: Extraction nombre décimaux.

From Olivier Miakinen <om+news@miakinen.net>
Newsgroups fr.comp.lang.regexp
Subject Re: Extraction nombre décimaux.
Date 2022-10-23 11:32 +0200
Organization There's no cabale
Message-ID <tj31nm$1nql$1@cabale.usenet-fr.net> (permalink)
References <635501d4$0$22259$426a74cc@news.free.fr>

Show all headers | View raw


Bonjour,

Le 23/10/2022 10:56, kurtz le pirate a écrit :
> 
> Je troune en rond depuis quelques temps sur l'extraction de nombre
> décimaux depuis un fichiers. je n'arrive pas à capturer le signe.

Je suggère :
/(?=[-+]?[0-9.])([-+]?)([0-9]*)(?:\.([0-9]+))?(?:e([0-9]+))?/g

L'assertion (?=[-+]?[0-9.]) au début permet de ne considérer que ce qui
ressemble déjà à un nombre (sinon ça matchera aussi la chaîne vide).

>   @floatnum = $line =~ /[-+]?([0-9]*\.[0-9]+|[0-9]+)/g;
> # @floatnum = $line =~ /($RE{num}{real})/g;
> # @floatnum = $line =~ /([+-]?\d+(\.\d+)?)/g;

Tu ne peux capturer qu'une seule chose à la fois ???

> 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

Je récupère :

-.168452
 "-"
 ""
 "168452"
 ""

0.456
 ""
 "0"
 "456"
 ""

-5.4563e6
 "-"
 "5"
 "4563"
 "6"


-- 
Olivier Miakinen

Back to fr.comp.lang.regexp | Previous | NextPrevious in thread | 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