{"id":518,"date":"2023-09-16T15:39:10","date_gmt":"2023-09-16T07:39:10","guid":{"rendered":""},"modified":"2023-09-17T00:42:13","modified_gmt":"2023-09-16T16:42:13","slug":"%e6%ad%a3%e5%88%99%e8%a1%a8%e8%be%be%e5%bc%8f%e5%8c%b9%e9%85%8d%e5%8f%8c%e5%bc%95%e5%8f%b7","status":"publish","type":"post","link":"https:\/\/mushiming.com\/518.html","title":{"rendered":"\u6b63\u5219\u8868\u8fbe\u5f0f\u5339\u914d\u53cc\u5f15\u53f7"},"content":{"rendered":"

\n <\/path> \n<\/svg> <\/p>\n

1.\u6b63\u5219\u8868\u8fbe\u5f0f\u5339\u914d\u5f15\u53f7<\/h2>\n

\u5339\u914d\u53cc\u5f15\u53f7\"<\/code>\u7528\\\"<\/code>
\u5339\u914d\u5355\u5f15\u53f7'<\/code>\u7528'<\/code><\/p>\n

2.\u6b63\u5219\u8868\u8fbe\u5f0f\u5339\u914d\u6b63\u5219\u8868\u8fbe\u5f0f\u4e2d\u7528\u5230\u7684\u7279\u6b8a\u7b26\u53f7\u65f6\u9700\u52a0\\\\<\/code><\/h2>\n

\u5982()[]{}\/|\\-+<\/code>
\u5339\u914d[<\/code>\u7528\\\\[<\/code>
\u5339\u914d]<\/code>\u7528\\\\]<\/code>
\u5339\u914d\\<\/code>\u7528\\\\\\\\<\/code>
\u5339\u914d\/<\/code>\u7528\\\\\/<\/code>
\u5339\u914d|<\/code>\u7528\\\\|<\/code>
\u5339\u914d-<\/code>\u7528\\\\-<\/code>
\u5339\u914d+<\/code>\u7528\\\\+<\/code><\/p>\n

\u5339\u914d\u5927\u5199\u82f1\u6587\u6216\u5c0f\u5199\u82f1\u6587\u6216\u6570\u5b57\u6216\u4e0b\u5212\u7ebf\u7528\\\\w<\/code>\u62160-9a-zA-Z_<\/code><\/p>\n

3.\u6b63\u5219\u8868\u8fbe\u5f0f\u4e2d\u5404\u79cd\u6269\u53f7()[]{}<\/code>\u4f5c\u7528<\/h2>\n

\u4e2d\u62ec\u53f7[]<\/code>\u8868\u793a\u5339\u914d\u5355\u4e2a\u5b57\u7b26\uff0c\u5339\u914d\u4e2d\u6269\u53f7\u91cc\u5217\u51fa\u7684\u4efb\u610f\u4e00\u4e2a\u5b57\u7b26<\/p>\n

[<\/span>dsa]<\/span>\/\/\u5339\u914dd\u6216s\u6216a<\/span>\n<\/code><\/pre>\n

\u5c0f\u62ec\u53f7\uff08\uff09<\/code>\u8868\u793a\u5339\u914d\u5b57\u7b26\u4e32\uff0c\u5339\u914d\u5c0f\u6269\u53f7\u91cc\u5217\u51fa\u7684\u6240\u6709\u5b57\u7b26\u6784\u6210\u7684\u5b57\u7b26\u4e32<\/p>\n

\uff08dsaff\uff09 \/\/\u4ec5\u80fd\u5339\u914ddsaff<\/span>\n<\/code><\/pre>\n

\u5927\u62ec\u53f7{}<\/code>\u8868\u793a\u5339\u914d\u7684\u6b21\u6570\uff0c\u653e\u4e8e()\u6216[]<\/code>\u4e4b\u540e<\/p>\n

[<\/span>dsa]<\/span>{ \n   <\/span>1<\/span>\uff0c8<\/span>}<\/span>\/\/\u5339\u914d1-8\u6b21[dsa],\u5982\u5339\u914dd,dd,dddddddd<\/span>\n<\/code><\/pre>\n
(<\/span>dsa)<\/span>{ \n   <\/span>1<\/span>\uff0c8<\/span>}<\/span>\/\/\u5339\u914d1-8\u6b21(dsa),\u5982\u5339\u914ddsa,dsadsadsadsadsadsadsadsa<\/span>\n<\/code><\/pre>\n

4.\u5e38\u7528\u5339\u914d\u4f8b\u5b50<\/h2>\n

\u4f8b\u5b50\uff08\u5339\u914d\u82f1\u8bed\u952e\u76d8\u4e0a\u7684\u4efb\u610f\u975e\u7a7a\u5b57\u7b26\uff09<\/h3>\n
\n QRegExp re<\/span>(<\/span>\"^[\\\\w~!@#$%^&*()+`={}:;<>?,.|'\\\"\\[\\\\]\\\\-\\\\\/\\\\\\\\]+$\"<\/span>)<\/span>;<\/span>\n   \n QString test<\/span>(<\/span>\"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ`1234567890-=~!@#$%^&*()_+[]{}|;:'\\\"\\\\\/,.<>?\"<\/span>)<\/span>;<\/span>\n\n bool match =<\/span> re.<\/span>exactMatch<\/span>(<\/span>test)<\/span>;<\/span>  \/\/match=true<\/span>\n<\/code><\/pre>\n

\u4f8b\u5b50\uff08\u5339\u914d\u4efb\u610f\u5408\u6cd5\u8868\u793a\u7684\u6709\u7406\u6570\uff09<\/h3>\n
\n QRegExp reg<\/span>(<\/span>\"^(\\\\-(?!0(?!\\\\.))|\\\\+(?!0(?!\\\\.)))?(0|[1-9]\\\\d*)(\\\\.\\\\d+)?$\"<\/span>)<\/span>;<\/span> \n   \n QString test<\/span>(<\/span>\"41424.4155346\"<\/span>)<\/span>;<\/span>\n\n bool match =<\/span> re.<\/span>exactMatch<\/span>(<\/span>test)<\/span>;<\/span>  \/\/match=true<\/span>\n<\/code><\/pre>\n

\u4f8b\u5b50\uff08\u5339\u914d\u4efb\u610f\u5408\u6cd5\u8868\u793a\u7684\u975e\u8d1f\u6709\u7406\u6570\uff09<\/h3>\n
\n QRegExp reg<\/span>(<\/span>\"^(\\\\+(?!0(?!\\\\.)))?(0|[1-9]\\\\d*)(\\\\.\\\\d+)?$\"<\/span>)<\/span>;<\/span> \n   \n QString test<\/span>(<\/span>\"41424.4155346\"<\/span>)<\/span>;<\/span>\n\n bool match =<\/span> re.<\/span>exactMatch<\/span>(<\/span>test)<\/span>;<\/span>  \/\/match=true<\/span>\n<\/code><\/pre>\n

\u4f8b\u5b50\uff08\u5339\u914d\u4efb\u610f\u5408\u6cd5\u8868\u793a\u7684\u6b63\u6709\u7406\u6570\uff09<\/h3>\n
\n QRegExp reg<\/span>(<\/span>\"^(\\\\+)?(0(?=\\\\.)|[1-9]\\\\d*)(\\\\.\\\\d+)?$\"<\/span>)<\/span>;<\/span> \n   \n QString test<\/span>(<\/span>\"41424.4155346\"<\/span>)<\/span>;<\/span>\n\n bool match =<\/span> re.<\/span>exactMatch<\/span>(<\/span>test)<\/span>;<\/span>  \/\/match=true<\/span>\n<\/code><\/pre>\n

\u4f8b\u5b50\uff08\u5339\u914d\u4efb\u610f\u5408\u6cd5\u8868\u793a\u7684\u6574\u578b\u6570\u5b57\uff09<\/h3>\n
\n QRegExp reg<\/span>(<\/span>\"^(\\\\-(?!0)|\\\\+(?!0))?(0|[1-9]\\\\d*)$\"<\/span>)<\/span>;<\/span>\n   \n QString test<\/span>(<\/span>\"414246\"<\/span>)<\/span>;<\/span>\n\n bool match =<\/span> re.<\/span>exactMatch<\/span>(<\/span>test)<\/span>;<\/span>  \/\/match=true<\/span>\n<\/code><\/pre>\n

\u4f8b\u5b50\uff08\u5339\u914d\u4efb\u610f\u5408\u6cd5\u8868\u793a\u7684\u975e\u8d1f\u6574\u578b\u6570\u5b57\uff09<\/h3>\n
\n QRegExp reg<\/span>(<\/span>\"^(\\\\+(?!0))?(0|[1-9]\\\\d*)$\"<\/span>)<\/span>;<\/span> \n   \n QString test<\/span>(<\/span>\"414246\"<\/span>)<\/span>;<\/span>\n\n bool match =<\/span> re.<\/span>exactMatch<\/span>(<\/span>test)<\/span>;<\/span>  \/\/match=true<\/span>\n<\/code><\/pre>\n

\u4f8b\u5b50\uff08\u5339\u914d\u4efb\u610f\u5408\u6cd5\u8868\u793a\u7684\u6b63\u6574\u578b\u6570\u5b57\uff09<\/h3>\n
\n QRegExp reg<\/span>(<\/span>\"^(\\\\+)?([1-9]\\\\d*)$\"<\/span>)<\/span>;<\/span> \n   \n QString test<\/span>(<\/span>\"414246\"<\/span>)<\/span>;<\/span>\n\n bool match =<\/span> re.<\/span>exactMatch<\/span>(<\/span>test)<\/span>;<\/span>  \/\/match=true<\/span>\n\n<\/code><\/pre>\n

\u4f8b\u5b50\uff08\u5339\u914d\u4efb\u610f\u5408\u6cd5\u8868\u793a\u7684\u5bc6\u7801\uff09<\/h3>\n
QRegExp reg<\/span>(<\/span>\"^[\\\\w~!@#$%^&*()+`={}:;<>?,.|'\\\"\\[\\\\]\\\\-\\\\\/\\\\\\\\]+$\"<\/span>)<\/span>;<\/span>\n        if<\/span> (<\/span>!<\/span>reg.<\/span>exactMatch<\/span>(<\/span>value.<\/span>data<\/span>(<\/span>)<\/span>)<\/span>)<\/span> { \n   <\/span>\n            message_ =<\/span>\n                QObject::<\/span>tr<\/span>(<\/span>\"The password can only contanin numbers, English \"<\/span>\n                            \"characters or special characters \"<\/span>)<\/span>\n                    .<\/span>toStdString<\/span>(<\/span>)<\/span>;<\/span>\n            return<\/span> false;<\/span>\n        }<\/span>\n        return<\/span> true;<\/span>\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"\u6b63\u5219\u8868\u8fbe\u5f0f\u5339\u914d\u53cc\u5f15\u53f7\u6b63\u5219\u8868\u8fbe\u5f0f\u5339\u914d\u53cc\u5f15\u53f7\uff08\u5305\u62ec\u5404\u79cd\u7279\u6b8a\u5b57\u7b26\u7684\u5339\u914d\uff09_\u6b63\u5219\u5339\u914d\u53cc\u5f15\u53f7","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[82],"tags":[],"_links":{"self":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/518"}],"collection":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/comments?post=518"}],"version-history":[{"count":0,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/518\/revisions"}],"wp:attachment":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/media?parent=518"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/categories?post=518"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/tags?post=518"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}