在notepad ++中,我需要一个正则表达式或模式来删除长度超过一定长度(比如50)的引号之间的字符串。请提供一个模板正则表达式,可用于"替换所有"消除在实际引号字符内的字符串,长度超过一定长度。
答案 0 :(得分:1)
我会这样做:
Environment:
Request Method: POST
Request URL: http://127.0.0.1:8000/comment/
Django Version: 1.9
Python Version: 2.7.12
Installed Applications:
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'stylizrApp']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware']
Traceback:
File "/home/l/Desktop/stylizr/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
149. response = self.process_exception_by_middleware(e, request)
File "/home/l/Desktop/stylizr/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
147. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/l/Desktop/stylizr/local/lib/python2.7/site-packages/django/views/generic/base.py" in view
68. return self.dispatch(request, *args, **kwargs)
File "/home/l/Desktop/stylizr/local/lib/python2.7/site-packages/django/views/generic/base.py" in dispatch
88. return handler(request, *args, **kwargs)
File "/home/l/Desktop/stylizr/local/lib/python2.7/site-packages/django/views/generic/edit.py" in post
221. return self.form_valid(form)
File "/home/l/Desktop/stylizr/src/stylizrApp/views.py" in form_valid
49. obj.save()
File "/home/l/Desktop/stylizr/local/lib/python2.7/site-packages/django/db/models/base.py" in save
700. force_update=force_update, update_fields=update_fields)
File "/home/l/Desktop/stylizr/local/lib/python2.7/site-packages/django/db/models/base.py" in save_base
728. updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
File "/home/l/Desktop/stylizr/local/lib/python2.7/site-packages/django/db/models/base.py" in _save_table
812. result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)
File "/home/l/Desktop/stylizr/local/lib/python2.7/site-packages/django/db/models/base.py" in _do_insert
851. using=using, raw=raw)
File "/home/l/Desktop/stylizr/local/lib/python2.7/site-packages/django/db/models/manager.py" in manager_method
122. return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/home/l/Desktop/stylizr/local/lib/python2.7/site-packages/django/db/models/query.py" in _insert
1039. return query.get_compiler(using=using).execute_sql(return_id)
File "/home/l/Desktop/stylizr/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py" in execute_sql
1064. cursor.execute(sql, params)
File "/home/l/Desktop/stylizr/local/lib/python2.7/site-packages/django/db/backends/utils.py" in execute
79. return super(CursorDebugWrapper, self).execute(sql, params)
File "/home/l/Desktop/stylizr/local/lib/python2.7/site-packages/django/db/backends/utils.py" in execute
64. return self.cursor.execute(sql, params)
File "/home/l/Desktop/stylizr/local/lib/python2.7/site-packages/django/db/utils.py" in __exit__
95. six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/home/l/Desktop/stylizr/local/lib/python2.7/site-packages/django/db/backends/utils.py" in execute
64. return self.cursor.execute(sql, params)
Exception Type: IntegrityError at /comment/
Exception Value: null value in column "post_comment_id" violates not-null constraint
DETAIL: Failing row contains (22, asda, 2016-08-05 17:18:07.513423+00, 1, null).
"[^"]{50,}"