Code Comments
Programming Forum and web based access to our favorite programming groups.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
Post Follow-up to this messageIn 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).
Post Follow-up to this message
"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
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.