For Programmers: Free Programming Magazines  


Home > Archive > AWK > September 2004 > metachar in awk 3.1.3 under cygwin









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author metachar in awk 3.1.3 under cygwin
Gilles DRIDI

2004-09-16, 10:51 am

Hello,

Please I'm trying to enter [ square left bracket in a regular expression
with awk 3.1.3 under cygwin. I use \[ but the system says :

warning: escape sequence '\[' treated as plain '['

how can I enter '[' in regular expression.

Thank you.
gdridi@club-internet.fr
http://perso.club-internet.fr/cdridi


Kenny McCormack

2004-09-16, 10:51 am

In article <41434bf2$0$308$7a628cd7@news.club-internet.fr>,
Gilles DRIDI <gdridi@club-internet.fr> wrote:
>Hello,
>
>Please I'm trying to enter [ square left bracket in a regular expression
>with awk 3.1.3 under cygwin. I use \[ but the system says :
>
>warning: escape sequence '\[' treated as plain '['
>
>how can I enter '[' in regular expression.


Hmmmm.

% gawk '/\[/'
foo[bar
foo[bar
foo
% gawk '/[/'
gawk: cmd. line:1: /[/
gawk: cmd. line:1: ^ unterminated regexp
gawk: cmd. line:2: /[/
gawk: cmd. line:2: ^ unexpected newline
%

Seems OK to me (Unix, tcsh, gawk 3.1.3).

Gilles DRIDI

2004-09-17, 8:55 am


"Kenny McCormack" <gazelle@yin.interaccess.com> a écrit dans le message de
news:ci9js3$c5d$1@yin.interaccess.com...
> In article <41484be1$0$15755$7a628cd7@news.club-internet.fr>,
> Gilles DRIDI <gdridi@club-internet.fr> wrote:
> --- Cut Here ---
> BEGIN {}
> {
> toto($0)
> }
>
> END {}
> function toto(t) {
> if ( match(t, "[[]") ) {
> print t, "[ found"
>
> # below sub(r, s, t) regular expression [ followed by ]
> # sub(substr(t, RSTART, RLENGTH), "", t)
> # instead of (thanks to Aharon Robbins)
>
> t= substr(t, 1, RSTART-1) substr(t, RSTART+RLENGTH)
> }
> }
> --- Cut Here ---
>
> And your point is?
>

It was just a post to, for the solution


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com