Re: replace substring
- From: Szabolcs Borsanyi <s.borsanyi@xxxxxxxxxxxx>
- Date: Mon, 26 May 2008 09:02:07 +0000 (UTC)
On Mon, May 26, 2008 at 12:29:05AM -0700, James Dow Allen wrote:
On May 26, 2:06 pm, magix <mag...@xxxxxxxxx> wrote:This sed solution seems to be off-topic, but, when applied to the OP's
I want to replace all the "\" to be "\\", so that
Try
sed ss\\\\s\\\\\\\\sg
source, could fix the C problem.
The OP should tell how he got that invalid string literal. If it his
own typing, he should replace the backslashes with pairs of backslashes,
either by hand or using the sed script above. (But it is unlikely to have
sed on a platform with path names containing lot's of backslashes.)
(you=OP)
On the other hand, it is an interesting question, how to replace
valid backslash characters in a string to pairs of backslashes, which can
be relevant, e.g. when writing a source code or passing the string to an
other picky application. If that is the case, you can do this replacement
on the course of copying each character to a separate character array.
Third point is, that it is possible to put a string into a character
array , like char path[]="d:\\path"; This character array cannot hold
more characters than it did originally, but feel free to put a big number
between the square brackets so that you do not have this limitation.
(This point is surely covered by the faq)
Szabolcs
.
YMMV
James Dow Allen
- References:
- replace substring
- From: magix
- Re: replace substring
- From: James Dow Allen
- replace substring
- Prev by Date: Re: replace substring
- Next by Date: Re: pointer size depends on what
- Previous by thread: Re: replace substring
- Next by thread: Re: replace substring
- Index(es):
Relevant Pages
|