Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #49274
| Path | csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'output': 0.05; 'skip:u 30': 0.07; 'output,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'separating': 0.09; 'subject:into': 0.09; 'python': 0.11; 'def': 0.12; 'jan': 0.12; '2.7': 0.14; '*args):': 0.16; 'dict': 0.16; 'ignoring': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'skip:f 60': 0.16; 'skip:q 30': 0.16; 'skip:u 60': 0.16; 'subject:selection': 0.16; 'subject:unicode': 0.16; 'unicode.': 0.16; 'vowel': 0.16; 'wrote:': 0.18; 'skip:f 30': 0.19; '>>>': 0.22; 'import': 0.22; 'issue.': 0.22; 'print': 0.22; 'header:User- Agent:1': 0.23; 'unicode': 0.24; 'this:': 0.26; 'tracker': 0.26; 'pass': 0.26; 'values': 0.27; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'asked': 0.31; 'code': 0.31; 'class': 0.32; 'another': 0.32; 'text': 0.33; 'checking': 0.33; 'framework': 0.33; 'skip:_ 10': 0.34; 'skip:s 30': 0.35; 'but': 0.35; 'there': 0.35; 'marks': 0.36; 'step': 0.37; 'being': 0.38; 'to:addr:python-list': 0.38; 'issue': 0.38; 'pm,': 0.38; 'does': 0.39; 'delete': 0.39; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; 'received:org': 0.40; 'skip:u 10': 0.60; 'new': 0.61; 'received:173': 0.61; 'email addr:gmail.com': 0.63; '8bit%:95': 0.64; '8bit%:100': 0.72; 'received:fios.verizon.net': 0.84; 'skip:\xe0 10': 0.84 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Terry Reedy <tjreedy@udel.edu> |
| Subject | Re: re.finditer() skips unicode into selection |
| Date | Wed, 26 Jun 2013 16:14:48 -0400 |
| References | <1d412b4a-b043-4723-909a-54c6c06cebd4@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8; format=flowed |
| Content-Transfer-Encoding | quoted-printable |
| X-Gmane-NNTP-Posting-Host | pool-173-75-251-66.phlapa.fios.verizon.net |
| User-Agent | Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130509 Thunderbird/17.0.6 |
| In-Reply-To | <1d412b4a-b043-4723-909a-54c6c06cebd4@googlegroups.com> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3899.1372277713.3114.python-list@python.org> (permalink) |
| Lines | 77 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1372277713 news.xs4all.nl 15954 [2001:888:2000:d::a6]:58929 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:49274 |
Show key headers only | View raw
On 6/26/2013 3:18 PM, akshay.ksth@gmail.com wrote:
> I am using the following Highlighter class for Spell Checking to work on my QTextEdit.
>
> class Highlighter(QSyntaxHighlighter):
> pattern = ur'\w+'
> def __init__(self, *args):
> QSyntaxHighlighter.__init__(self, *args)
> self.dict = None
>
> def setDict(self, dict):
> self.dict = dict
>
> def highlightBlock(self, text):
> if not self.dict:
> return
> text = unicode(text)
> format = QTextCharFormat()
> format.setUnderlineColor(Qt.red)
> format.setUnderlineStyle(QTextCharFormat.SpellCheckUnderline)
> unicode_pattern=re.compile(self.pattern,re.UNICODE|re.LOCALE)
>
> for word_object in unicode_pattern.finditer(text):
> if not self.dict.spell(word_object.group()):
> print word_object.group()
> self.setFormat(word_object.start(), word_object.end() - word_object.start(), format)
>
> But whenever I pass unicode values into my QTextEdit the re.finditer() does not seem to collect it.
>
> When I pass "I am a नेपाली" into the QTextEdit. The output is like this:
>
> I I I a I am I am I am a I am a I am a I am a I am a I am a I am a I am a
>
> It is completely ignoring the unicode.
The whole text is unicode. It is ignoring the non-ascii, as you asked it
to with re.LOCALE.
With 3.3.2:
import re
pattern = re.compile(r'\w+', re.LOCALE)
text = "I am a नेपाली"
for word in pattern.finditer(text):
print(word.group())
>>>
I
am
a
Delete ', re.LOCALE' and the following are also printed:
न
प
ल
There is an issue on the tracker about the vowel marks in नेपाली being
mis-seen as word separators, but that is another issue.
Lesson: when you do not understand output, simplify code to see what
changes. Separating re issues from framework issues is a big step in
that direction.
? What might be the issue. I am new to PyQt and regex. Im using Python
2.7 and PyQt4.
--
Terry Jan Reedy
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
re.finditer() skips unicode into selection akshay.ksth@gmail.com - 2013-06-26 12:18 -0700
Re: re.finditer() skips unicode into selection Terry Reedy <tjreedy@udel.edu> - 2013-06-26 16:14 -0400
Re: re.finditer() skips unicode into selection MRAB <python@mrabarnett.plus.com> - 2013-06-26 21:24 +0100
Re: re.finditer() skips unicode into selection darpan6aya <akshay.ksth@gmail.com> - 2013-06-26 20:26 -0700
Re: re.finditer() skips unicode into selection darpan6aya <akshay.ksth@gmail.com> - 2013-06-26 20:31 -0700
Re: re.finditer() skips unicode into selection darpan6aya <akshay.ksth@gmail.com> - 2013-06-26 20:39 -0700
Re: re.finditer() skips unicode into selection darpan6aya <akshay.ksth@gmail.com> - 2013-06-26 21:25 -0700
csiph-web