正则表达式-找到正确的模式 [英] Regular Expression - Finding the proper pattern
问题描述
我有一个基于正则表达式模式验证字符串(邮件主题行)的系统.
我提供-输入字符串和模式,它验证是或否.
我无法访问执行此操作的代码(或更糟糕的是,我什至不知道它所编码的是什么).只是正则表达式模式!
情况1:
Hi,
I''ve a system which validates a string (a mail subject line) based on a regular expression pattern.
I provide - Input string and Pattern and it validates yes or no.
I''ve NO ACCESS to code which does that (or worse, I don''t even know what it''s coded upon). Just the Regular Expression pattern!
Case 1:
Input: FW: 12334-123-412 my-name test mail
Pattern: \bmy-name\b
Validation: Successful
情况2:
Case 2:
Input: FW: 12334-123-412 my-name test mail
Pattern: \bMy-name\b
Validation: Failed
我需要使其不区分大小写,因此我尝试了模式(?i)(\ bmy-name \ b)
I need to make it case insensitive, hence I tried the pattern (?i)(\bmy-name\b)
Input: FW: 12334-123-412 my-name test mail
Pattern: (?i)(\bMy-name\b)
Validation: Failed
您可以在不了解比较代码的情况下以正确的模式帮助我吗?
还是给我一套可能用于测试的模式?
Can you help me with the proper pattern, having no knowledge of the comparison code?
or give me a set of possible patterns that I might use to test out?
推荐答案
尝试使用此
http://www.w3schools.com/jsref/jsref_regexp_i.asp [
Try this
http://www.w3schools.com/jsref/jsref_regexp_i.asp[^]
强力?
Brute force?
\b[Mm][Yy]-[Nn][Aa][Mm][Ee]\b
安迪
Andi
这篇关于正则表达式-找到正确的模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!