大家好 ! ! !我正在创建一个项目。在它之间我被卡住了,因为我想要一个代码被接受和验证 [英] Hello all ! ! ! I am creating a project. In between it I am stuck , as I want one code to be accepted and validted

查看:90
本文介绍了大家好 ! ! !我正在创建一个项目。在它之间我被卡住了,因为我想要一个代码被接受和验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我告诉用户输入4563217876,那么只有在匹配时它才会继续,它将恢复正常。我在visualC中创建它#

任何人都可以在这方面提供帮助吗?



我尝试了什么:



i尝试使用regex命令,但它需要任何数字,但我希望程序只接受一个代码。例如5436789543

if i tell a user to enter 4563217876 then only it will proceed if not matched it will return to normal. i am creating it in visualC#
can anyone help in this regard??

What I have tried:

i have tried using regex command but it takes any number but i want the program to accept only one code. for eg 5436789543

推荐答案

正则表达式是文本匹配程序,并不适合完全匹配,尽管yopu可以做到。例如,以下正则表达式仅匹配您的示例:

Regexes are text matching programs, and are not ideal for exact matches, although yopu can do it. For example, the following Regex will only match your example:
^4563217876




但是......在C#中,它比这更容易,你根本不需要正则表达式:


But ... in C#, it's easier than that, you don't need a Regex at all:

public bool DoesThisMatch(string input)
   {
   return input == "4563217876";
   }


这篇关于大家好 ! ! !我正在创建一个项目。在它之间我被卡住了,因为我想要一个代码被接受和验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆