我需要正则表达式来匹配长度为 11 个字符的字母数字字符串,但该值必须至少包含 1 个字符和 1 个数字。
使用Regex的组合来 表示至少有 1 个数字和 1 个字符的字母数字
IE /^(?=.*[0-9])(?=.*[a-zA-Z])([a-zA-Z0-9]+)$/
IE ^[a-zA-Z0-9]{6,}$
通过像这样使用 OR (||) 运算符
//regex code
var str = "";
if ($.trim($("input[id$='txtBranchName']").val()) != "")
str = $.trim($("input[id$='txtBranchName']").val());
var reg_exp = /^(?:[0-9]+[a-z]|[a-z]+[0-9])[a-z0-9]*$/i; // /^[a-zA-Z0-9]{11,}$/;//^(\d)(?:\1+)?$/; // new RegExp('([0-9]){6}');
var reg_exp2 = /^[a-zA-Z0-9]{11,11}$/;
if (!reg_exp.test(str) || !reg_exp2.test(str)) {
$("span[id$='lblError']").css("color", "red");
$("span[id$='lblError']").html($("span[id$='lbl_PayeeInformation_IFSCNo']").html()).show();
$("input[id$='txtBranchName']").focus();
returned = false;
return false;
}
//end regex code
Run Code Online (Sandbox Code Playgroud)
但如果我在一个正则表达式中得到它会很棒。
如何在数据库中存储Image,然后使用MVC检索和显示它
我在用
MVC3
Entity Framework Database First
Run Code Online (Sandbox Code Playgroud)
和
SQL SERVER 2008
Run Code Online (Sandbox Code Playgroud)
在数据库中,我使用varbinary(MAX)作为图像
Image varbinary(MAX) Checked
Run Code Online (Sandbox Code Playgroud)
我还用过
[DisplayName("Image")]
public byte[] Image { get; set; }
Run Code Online (Sandbox Code Playgroud)
在我的映射类中
当我尝试将其保存在我的创建操作方法中时
public ActionResult Create(MarjaaModel newMarjaa, HttpPostedFileBase uploadFile)
{
if (uploadFile != null && uploadFile.ContentLength > 0)
{
newMarjaa.Image = new byte[uploadFile.ContentLength];
uploadFile.InputStream.Read(newMarjaa.Image, 0, uploadFile.ContentLength);
}
try
{
data.submitMarjaa(newMarjaa);
return RedirectToAction("Index");
}
catch
{
return View();
}
}
Run Code Online (Sandbox Code Playgroud)
我成功将图像保存为二进制数据
但是Plz告诉我如何检索这个图像并在我的视图中显示它