Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/259.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 我做错了什么?错误消息未显示_C#_Javascript_Html_Regex - Fatal编程技术网

C# 我做错了什么?错误消息未显示

C# 我做错了什么?错误消息未显示,c#,javascript,html,regex,C#,Javascript,Html,Regex,我有一个多行文本框,不允许用户输入任何HREF链接。 所以我尝试使用正则表达式进行字符串匹配,如下所示。 但我没有收到错误信息。我做错了什么 Regex strMatch = new Regex(@"^(?:(?:<a )?href|</a>)", RegexOptions.Compiled | RegexOptions.IgnoreCase); if (strMatch.IsMatch(EmailTextBox.Text.Trim())) { vsumPage.Add

我有一个多行文本框,不允许用户输入任何HREF链接。 所以我尝试使用正则表达式进行字符串匹配,如下所示。 但我没有收到错误信息。我做错了什么

Regex strMatch = new Regex(@"^(?:(?:<a )?href|</a>)", RegexOptions.Compiled | RegexOptions.IgnoreCase);
if (strMatch.IsMatch(EmailTextBox.Text.Trim()))
 {
   vsumPage.AddErrorMessage("Cannot enter links");
 }
Regex stratch=新的正则表达式(@“^(?):
再次更新: 尝试了如下所示的方法: 但它总是出现在警报“Test3 0”部分…即使
          function doPreview()
      {
          var getEncodedStr = encode("<%=EmailTextBox.ClientID%>"); 
          var strInvalid = "Email instructions cannot have links included";
          var checkCount = "0" ;
          alert("Test 1" + checkCount);
          if(/<\/[\s\S]?a\b/gm.test(decode(getEncodedStr)))
          { 
            checkCount = "1" ;
            alert("Test 2" + checkCount);
            alert((/<\/?a\b/.test(decode(getEncodedStr))));
            return false;
          }
          if (checkCount == "0")
          {                  
            alert("Test 3" + checkCount);
            var targetURL = 'EPreview.aspx?txtName=' + getEncodedStr ;
            window.open(targetURL, null, "height=700,width=600,dependent=yes,hotkey=no,menubar=no,resizable=yes,scrollbars=yes,status=no,titlebar=no,toolbar=no");
            return false;
          }
      }
function doPreview()
{
var getEncodedStr=encode(“”);
var strInvalid=“电子邮件说明不能包含链接”;
var checkCount=“0”;
警报(“测试1”+检查计数);

如果(/The
^
断言此模式出现在字符串的开头。请尝试删除它。您也可以将此模式更改为:

@"</?a\b"

@“你用的字符串是什么?马上,它看起来我可以拥有,而且它会接受。为什么投票结果如此接近?这里的每一个正则表达式问题都是“如何编写正则表达式来检测诸如此类的废话”。回答总是“你尝试了什么?”。迪蒂实际上告诉了我们他尝试了什么,但显然现在是这样了“太本地化了”?完成了。你能检查一下,让我知道我做错了什么吗?我也需要在JS中进行同样的检查。我正在使用以下内容,但它给了我一些例外(请查看更新并帮助我。谢谢。@dity请再次尝试我的正则表达式,我有一个无关的
在那里。是的,这很有效。非常感谢。我如何在JS中测试它?JS也给出了一些错误。@dity使用相同的模式,但转义斜杠:
/
          function doPreview()
      {
          var getEncodedStr = encode("<%=EmailTextBox.ClientID%>"); 
          var strInvalid = "Email instructions cannot have links included";
          var checkCount = "0" ;
          alert("Test 1" + checkCount);
          if(/<\/[\s\S]?a\b/gm.test(decode(getEncodedStr)))
          { 
            checkCount = "1" ;
            alert("Test 2" + checkCount);
            alert((/<\/?a\b/.test(decode(getEncodedStr))));
            return false;
          }
          if (checkCount == "0")
          {                  
            alert("Test 3" + checkCount);
            var targetURL = 'EPreview.aspx?txtName=' + getEncodedStr ;
            window.open(targetURL, null, "height=700,width=600,dependent=yes,hotkey=no,menubar=no,resizable=yes,scrollbars=yes,status=no,titlebar=no,toolbar=no");
            return false;
          }
      }
@"</?a\b"