C#代码生成与正则表达式匹配的字符串 [英] C# Code to generate strings that match a regex
问题描述
我使用正则表达式来验证用户输入.现在,我可以配置正则表达式,因此它可以帮助用户查看确定输入格式的示例.
I use regular expressions to validate user input. Now I can configure the regex and so it would help the user to see an example of how a certaint input has to be formatted.
是否可以生成一些与任意正则表达式匹配的字符串?甚至在某个地方有可用的实现吗?
Is it possible to generate some strings that match an arbitrary regex? And is there even an implementation usable somewhere?
更新:由于许可证,我不能使用REX.还有其他可能性吗?
UPDATE: Due to the licence I can not use REX. Are there other possiblities?
推荐答案
尝试使用此应用程序Rex可以做到这一点:)
Try using this app Rex can do this :)
http://research.microsoft.com/en-us/projects/rex/
对于Java,它是 https://code.google.com/p/xeger/
因此有很多正则表达式匹配生成器:)
So there are many regex matches generators :)
这: https://github.com/moodmosaic/Fare
它是C#中的xeger包装器
It's xeger wrapper in c#
这篇关于C#代码生成与正则表达式匹配的字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!