amoura has asked for the wisdom of the Perl Monks concerning the following question:

Hello monks,, I have this data in a file :
[\sbs]\v5\strans.cxx@@\main\den\7 [\sbs]\v5\c\ns.cxx@@\main\den\7 [\sbs]\v5\c\ans.h@@\main\den\3
I want to take off the prakits [] arount the sbs , I want my data to look like this
\sbs\v5\strans.cxx@@\main\den\7 \sbs\v5\c\ns.cxx@@\main\den\7 \sbs\v5\c\ans.h@@\main\den\3
thanks for help

Replies are listed 'Best First'.
Re: regex problem
by Abigail-II (Bishop) on Jul 23, 2002 at 13:49 UTC
    perl -wi -ple 'tr[[]][]d' your_file
    Abigail
Re: regex problem
by jmcnamara (Monsignor) on Jul 23, 2002 at 13:52 UTC

    Have a look at tr() on the perlop manpage:     $str =~ tr/[]//d;

    --
    John.

Re: regex problem
by dimmesdale (Friar) on Jul 23, 2002 at 13:52 UTC
    If you know its the only brackets in the file, try:

    $data =~ s/[\[\]]//g;

    Or, to be safe, if the brackets are always around sbs, try:

    $data =~ s/\[(\\sbs)\](.*)/$1$2/;
Re: regex problem
by amphiplex (Monk) on Jul 23, 2002 at 13:52 UTC
      thanks to you all
Re: regex problem
by adso (Initiate) on Jul 23, 2002 at 14:10 UTC

    Assuming $x contains a line of your input file,

    $x =~ s/[\[\]]//g;

    should do the trick