Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Small but dangerous bug in StrExtract
Message
De
15/08/2008 14:49:44
 
 
À
15/08/2008 14:35:03
Information générale
Forum:
ASP.NET
Catégorie:
Visual FoxPro Toolkit pour .NET
Divers
Thread ID:
01339105
Message ID:
01339212
Vues:
7
This is the C# code I believe:
    public static string StrExtract(string cSearchExpression, string cBeginDelim, string cEndDelim, int nBeginOccurence, int nFlags) {
        string cstring = cSearchExpression;
        string cb = cBeginDelim;
        string ce = cEndDelim;
        string lcRetVal = "";
        if ((nFlags == 1)) {
            cstring = cstring.ToLower();
            cb = cb.ToLower();
            ce = ce.ToLower();
        }
        // Lookup the position in the string
        int nbpos = VFPToolkit.strings.At(cb, cstring, nBeginOccurence);
        if ((cSearchExpression.Substring(nbpos, ce.length) != ce)) {
            int nepos = cstring.IndexOf(ce, (nbpos + 1));
            // Extract the part of the strign if we get it right
            if ((nepos > nbpos)) {
                lcRetVal = cSearchExpression.Substring(nbpos, (nepos - nbpos));
            }
            else if ((nepos < 1)) {
                lcRetVal = cSearchExpression.Substring(nbpos);
            }
        }
        return lcRetVal;
    }
Glenn
>>The current implementation of StrExtract in the VFPToolkit will fail if there is no data between a both delimiters when the delimiter length is 1.
>>
~abc~def~~jkl~
>>will return "~jkl" for StrExtract(lcString,"~'","~",3)
>>
>>To correct the code and to allow missing right delimiter use the following code
>
>How to convert this code to C# ?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform