Re: Suggest new fixed flag for s command?

Brandon W Maister <[email protected]>
Newsgroups gmane.editors.sed.user
Message-ID <CANNZFEkbDE24t7o3Hu5-UpJn3isZ4dQdA-zjesNUsohi07XCZw@mail.gmail.com>
FWIW in every language that I know of that implements this feature it's
implemented as [raw strings] with an 'r' (sometimes 'R') flag. "Raw regular
expression" doesn't really make sense, but the term and flag will be
recognized by programmers.

I, too, have occasionally wanted this.

[raw strings] https://www.google.com/search?q=raw+string

brandon



On Thu, May 9, 2013 at 2:48 AM, Pedro Izecksohn <[email protected]> wrote:

>   The character f may mean fixed, but it also may mean flag. I thought
> about a command that would clear the state of the substitution flag, but as
> I'm minimalist ... I'm against any new command that is not strictly
> necessary, where necessary means not replaceable. Why? Every new command
> makes the switch loop longer, IOW: makes sed run slower.
>
>   A much more useful command would: Take the hold space and compile it as
> a regular expression; to be used by the next empty regular expression, that
> is // . The character for such command: I'd use C ompile.
>
> ----- Original Message -----
> > From: Thierry Blanc <Thierry.Blanc@...>
> > To: Daniel <dagoldman@...>
> > Cc: [email protected]
> > Sent: Wednesday, May 8, 2013 3:20 PM
> > Subject: Re: Suggest new fixed flag for s command?
> >
> > very good idea.
> >
> > to not escape strings by hand, you can use preprocessing, something like:
> >
> > echo 'jj*hh.?' | sed 's|[.?*]|\\&|g'
> >
> > On 05/08/2013 11:27 AM, Daniel wrote:
> >>  I have run into a situation sometimes where literal strings I want to
> > replace that have metacharacters, and I want to replace it with some
> other
> > similarly odd string.
> >>
> >>  For example, suppose I want to replace the literal string "jj*hh"
> > with the literal string "foo\1bar".
> >>
> >>  To make it work, I would have to use escape characters:
> >>
> >>  $ echo 'jj*hh' | sed 's/jj\*hh/foo\\1bar/'
> >>  foo\1bar
> >>
> >>  I don't mind doing this for one or two strings, but sometimes I have a
> > lot of strings, and don't want to escape them all by hand or write some
> > complex script procedure.
> >>
> >>  What if the s command could have a f "fixed" flag, similar to the
> > grep -F fixed flag, so the following would work:
> >>
> >>  $ echo 'jj*hh' | sed 's/jj*hh/foo\1bar/f'
> >>  foo\1bar
> >>
> >>  The f flag would tell s to ignore all metacharacters, to just
> interpret A
> > and B in s/A/B/f as fixed strings.
> >>
> >>  Maybe there is some simpler way to do this I am overlooking? Anyway,
> just a
> > suggestion.
> >>
>
>
> ------------------------------------
>
> --
> Yahoo! Groups Links
>
>
>
>


[Non-text portions of this message have been removed]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.