[prev in list] [next in list] [prev in thread] [next in thread] 

List:       koffice
Subject:    Re: Simple QRegExp question
From:       Stephan Kulow <coolo () kde ! org>
Date:       2001-03-09 10:51:48
[Download RAW message or body]

Enno Bartels wrote:
> 
> Hi
> 
> I'am just working on a new version of the
> applixword input filter.
> But I have a problem.
> 
> Can someone tell me how I can convert
> \"
> to
> "
> I will  do that with QRegExp but it didn't worked
> and the qt docs can't help me at that point.

Wait til you try to convert \\ to \ - been there :)

> 
> If I convert
> >
> to
> &gt;
> I use
>    textstr.replace (QRegExp (">"), "&gt;");
> 
> And so my solution for
> \"
> to
> "
> is that one:
>           textstr.replace (QRegExp ("\\\""), "\"");
> but it didn't does what I wanted.
> 
That's how I would do it too, but with some batteling,
I use this (even though my problem was a bit more about
escaped \s that escape \"s):
    index = 0;
    while (true) {
        index = msgid.find("\\\"", index);
        if (index == -1)
            break;
        if (index > 1 && msgid.at(index - 1) == '\\' && msgid.at(index -
2) != '\\')
            msgid.replace(index - 1, 3, "\\\"");
        else
            msgid.replace(index, 2, "\"");
    }

I think, \\\" is the way you write it for QString and QRegExp expects
each \ to be escaped once more, so you end up with 
\\\\\\", 

Greetings, Stephan

-- 
People in cars cause accidents. Accidents in cars cause people.

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic