小编Tom*_*Tom的帖子

前缀排除的正则表达式

我试图从一个段落中提取gmail.com,我只希望那些不以@开头的字符串匹配.

示例:abc@gmail.com(不匹配); www.gmail.com(匹配此)

我尝试了以下内容:(?!@)gmail\.com但这不起作用.这与上面示例中突出显示的案例相匹配.有什么建议?

regex

4
推荐指数
2
解决办法
9016
查看次数

为什么即使值相同,哈希表中的值比较也会返回false?

在下面的代码中,我试图检查两个字符串是否是字谜.为此,我计算哈希表中两个字符串中的字符,方法是将唯一字符作为键存储,并将其作为值存储在字符串中.最后,当我去检查,如果每个角色都具有相同的数,我得到一个错误的输出中看到标示为代码"问题"就行了.但是当我将该行中的值转换为字符串时,代码工作正常.我错过了什么?

    static bool AreAnagrams(string input1, string input2)
    {
        Hashtable uniqueChars1 = new Hashtable();
        Hashtable uniqueChars2 = new Hashtable();

        // Go through first string and create a hash table of characters 
        AddToHashTable(input1, ref uniqueChars1);
        // Go through second string and create a second hash table of characters
        AddToHashTable(input2, ref uniqueChars2);

        // For each unique character, if the count from both hash tables are the same, they are anagrams
        if (uniqueChars1.Keys.Count != uniqueChars2.Keys.Count)
        {
            return false;
        }
        else
        {
            foreach (object key …
Run Code Online (Sandbox Code Playgroud)

c# hashtable

3
推荐指数
1
解决办法
671
查看次数

标签 统计

c# ×1

hashtable ×1

regex ×1