[Psi-Devel] [Patches] [Patch] Spell checker doesn't handle abbreviated words

Michail Pishchagin mblsha at gmail.com
Mon Jul 21 16:03:39 PDT 2008


On 17.07.2008, at 13:38, Norman Rasmussen wrote:

> On Thu, Jul 17, 2008 at 12:30 AM, Michail Pishchagin  
> <mblsha at gmail.com> wrote:
>        // Match words (minimally)
>        static QRegExp expression("\\b\\w+\\b");
>        static QRegExp number("^\\d+$");
>
>        // Iterate through all words
>        int index = text.indexOf(expression);
>        while (index >= 0) {
>                int length = expression.matchedLength();
>                if (expression.cap().indexOf(number) >= 0) {
>                        // skipping numbers
>                }
>
> Using expression("\\w[\\w']*\\w") should still work right?

Very likely, I'd prefer to get a unit-test first in order to make sure  
it works.

> Why not use number.exactMatch(str) instead of str.indexOf(number) >=  
> 0 ? (same logic, I think it's easier to read)

In case of ^foo$ regexp it should work the same, but most of the time  
I'm happy with partial matches too and got used to this way of doing  
things. I don't hold hard feelings for indexOf() as long as everything  
works alright.

-Michail


More information about the Psi-Devel mailing list