Ticket #12119: 12119.smart_split_with_space.diff
File 12119.smart_split_with_space.diff, 1.2 KB (added by , 15 years ago) |
---|
-
django/utils/text.py
200 200 # Expression to match some_token and some_token="with spaces" (and similarly 201 201 # for single-quoted strings). 202 202 smart_split_re = re.compile(r""" 203 ([^\s"]*"(?:[^"\\]*(?:\\.[^"\\]*)*)"\S*| 204 [^\s']*'(?:[^'\\]*(?:\\.[^'\\]*)*)'\S*| 205 \S+)""", re.VERBOSE) 203 ((?: 204 [^\s'"]* 205 (?: 206 (?:"(?:[^"\\]|\\.)*" | '(?:[^'\\]|\\.)*') 207 [^\s'"]* 208 )+ 209 ) | \S+) 210 """, re.VERBOSE) 206 211 207 212 def smart_split(text): 208 213 r""" -
tests/regressiontests/text/tests.py
27 27 [u'url', u'search_page', u'words=hello'] 28 28 >>> list(smart_split(u'url search_page words="something else')) 29 29 [u'url', u'search_page', u'words="something', u'else'] 30 >>> list(smart_split("cut:','|cut:' '")) 31 [u"cut:','|cut:' '"] 30 32 31 33 ### urlquote ############################################################# 32 34 >>> from django.utils.http import urlquote, urlquote_plus