bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug-gawk] There are cases where regexp in FPAT does not work


From: Hyunho Cho
Subject: [bug-gawk] There are cases where regexp in FPAT does not work
Date: Fri, 8 Feb 2019 13:26:13 +0900

$ awk --version
GNU Awk 4.2.1, API: 2.0 (GNU MPFR 4.0.1, GNU MP 6.1.2)
Copyright (C) 1989, 1991-2018 Free Software Foundation.

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.10
Release:        18.10
Codename:       cosmic

$ uname -a
Linux EliteBook 4.18.0-14-generic #15-Ubuntu SMP Mon Jan 14 09:01:02
UTC 2019 x86_64 x86_64 x86_64 GNU/Linux


#####################################################################


There are cases where regexp in FPAT does not work.
If i change "{{111}}"  to "{{AAA}} in input string and
FPAT='{{[A-Z]+}}' then it WORK


### FPAT='{{[0-9]+}}' NOT WORK!
$ echo '{{111}} design will serve {{111}} ...' |
awk '{ gsub($1,"xxx",$0); print  }' FPAT='{{[0-9]+}}'
{{111}} design will serve {{111}} ...

### FPAT='{{[0-9]+}' NOT WORK!
$ echo '{{111}} design will serve {{111}} ...' |
awk '{ gsub($1,"xxx",$0); print  }' FPAT='{{[0-9]+}'
{{111}} design will serve {{111}} ...

### FPAT='{[0-9]+}' WORK!
$ echo '{{111}} design will serve {{111}} ...' |
awk '{ gsub($1,"xxx",$0); print  }' FPAT='{[0-9]+}'
{xxx} design will serve {xxx} ...

### FPAT='{[0-9]+}}' WORK!
$ echo '{{111}} design will serve {{111}} ...' |
awk '{ gsub($1,"xxx",$0); print  }' FPAT='{[0-9]+}}'
{xxx design will serve {xxx ...

###  WORK!
$ echo '{{111}} design will serve {{111}} ...' |
awk '{ gsub("{{[0-9]+}}","xxx",$0); print  }'
xxx design will serve xxx ...

### NOT WORK!
$ echo '[[111]] design will serve [[111]] ...' |
awk '{ gsub($1,"xxx",$0); print  }' FPAT='\\[\\[[0-9]+]]'
[[11xxx] design will serve [[11xxx] ...

### WORK!
$ echo '[[111]] design will serve [[111]] ...' |
awk '{ gsub("\\[\\[[0-9]+]]","xxx",$0); print  }'
xxx design will serve xxx ...



reply via email to

[Prev in Thread] Current Thread [Next in Thread]