解决方案 »

  1.   

    我给你写个js 版的,不用正则string s = 'You re'
    s.replace(' ','\'');string ss = '<speak  .....'
    ss.substring(s.indexof('xml:lang')+1,ss.length);
      

  2.   

    第一个感觉不大适合用正则,变化太多,你想想用其他办法第二个
                Regex reg = new Regex(@"(?<=xml:lang=)(['""]?)(?<lan>[^'""]+)\1");
                Console.WriteLine(reg.Match(str).Groups["lan"].Value);
      

  3.   

    第一个:([a-zA-z]+[\s{1,}][re|s|ll|d|m]+)
    测试为true时,则替换,否则不替换。
      

  4.   

    1、 Regex.Replace("You re", @"\s", "'");
    2、 str="<speak version=\"1.0\" xmlns=\"http://www.w3.org/2001/10/synthesis\" xmlns:mstts=\"http://www.w3.org/2001/mstts\" xmlns:emo=\"http://www.w3.org/2009/10/emotionml\" xml:lang=\"en-us\">";
                all = Regex.Matches(str, "xml:lang=[\"\'][\\w\\W]*[\"\']");              foreach (Match item in all)
                {
                    Console.WriteLine(item.Value);
                }
      

  5.   

    你的这种写法不严谨,我后面跟r或者l也能匹配成功
    的确如此,再改下试试:([a-zA-z]+[\s{1,}](re|s|ll|d|m)$)
    应该能满足LZ所列的几种情况。
      

  6.   


    Regex regex = new Regex(@"(?<=\b[a-z]+\b)\s(?=\b(?:d|ll|m|re|s)\b)", RegexOptions.IgnoreCase);
    Console.WriteLine(regex.Replace("I m the first VIP and you ll be VIP, too. So we re all VIPs. I d like to tell you what s up.", "'"));
    regex = new Regex(@"\bxml:lang=(?<langCtry>""[^""]+""|'[^']+')", RegexOptions.IgnoreCase);
    Console.WriteLine(regex.Replace("<speak version='1.0' xmlns='http://www.w3.org/2001/10/synthesis' xmlns:mstts='http://www.w3.org/2001/mstts' xmlns:emo='http://www.w3.org/2009/10/emotionml' xml:lang='en-us'>", "--${langCtry}--"));// 自己稍微组织一下,就可以了。
      

  7.   

    我是楼主,楼上的,其实你还忘记了我的第一个题目中在what s和I m这两个还有个双引号,需要把双引号去掉,在在中间空格填补一个‘
    "What s" => What's
    "You ll" => You'll
    "I m" => I'm
    所以我估计一步无法实现吧
      

  8.   

    哎,加个引号你就不会了吗?还无法实现,脑子动都不动。
    (?<=\b[a-z]+\b)\s(?=\b(?:d|ll|m|re|s)\b)
    (?<=""\b[a-z]+\b)\s(?=\b(?:d|ll|m|re|s)\b"")

      

  9.   

    问题2是Cortana返回的TTS语音。楼主在研究什么?