英文字母:[a-zA-Z]
數字:[0-9]
匹配中文,英文字母和數字及_:
^[\u4e00-\u9fa5_a-zA-Z0-9]+$
同時判斷輸入長度:
[\u4e00-\u9fa5_a-zA-Z0-9_]{4,10}
^[\w\u4E00-\u9FA5\uF900-\uFA2D]*$ 1、一個正則表達式,只含有漢字、數字、字母、下劃線不能以下劃線開頭和結尾:
^(?!_)(?!.*?_$)[a-zA-Z0-9_\u4e00-\u9fa5]+$ 其中:
^ 與字符串開始的地方匹配
group和groups是兩個不同的函數。
一般,m.group(N) 返回第N組括號匹配的字符。
而m.group() == m.group(0) == 所有匹配的字符,與括號無關,這個是API規定的。
m.groups() 返回所有括號匹配的字符,以tuple格式。
m.groups() == (m.group(0), m.group(1), ...)
If you dont't want HTML escaped, look at the safe
filter
and the autoescape
tag
FILTER: {{
myhtml |safe }}
http://docs.djangoproject.com/en/dev/ref/templates/builtins/#safe
TAG: {%
autoescape off %}{{ myhtml }}{% endautoescape %}
http://docs.djangoproject.com/en/dev/ref/templates/builtins/#autoescape