[BRLTTY] Prompt matching.
Aura Kelloniemi
kaura.dev at sange.fi
Tue Oct 9 07:17:31 EDT 2018
Hi
Dave Mielke <Dave at mielke.cc> writes:
> [quoted lines by Aura Kelloniemi on 2018/10/09 at 11:22 +0300]
> >But it probably does not help if the pattern contains a dot to match a single
> >character, which happens to be a non-ASCII character in the input. E.g. a
> >pattern ".> " will not match "λ> ". Am Iright?
> Yes, but, if we do some clever parsing, we could translate each dot to
> something like:
> (?:[\x00-\x7f]|[\xc0-\xff][\x80-\xbf]*)
This might work. Though it might become a nightmare for the user if their
regular expression is malformed and they get back an error message which
really does not make any sense to them. I don't know if POSIXregex library has
any error reporting capabilities though.
> I'm wondering, though, if we should just maybe insist on the use of pcre2
> because it supports wchar_t which brltty uses. Then we wouldn't have to do any
> parsing, character reencoding, etc, and it should just work. Brltty even
> already converts the UTF-8 characters in data files to wchar_t for processing.
My personal opinion would be yes.
> What I don't know is how pcre2 pattern syntax differs from that of POSIX
> extended regular expressions. In case you remind me that it's similar to Perl,
> I'll answer that I've never liked Perl so haven't learned much of it. :-)
I never liked Perl either. The only thing that I like about Perl though is its
regular expression syntax. Its escaping rules are more consistent than
POSIX's, it has many very convenient additional matchers, like \d for
[[:digit:]] and \s for [[:space:]]. It supports unicode properties - for
example \w can be configured to take into account all Unicode letters. I
personally like comments a lot in PCRE (?# Because they make long regexes
comprehensible again). PCRE's article on Wikipedia is very comprehensive and a
good read for the topic:
https://en.wikipedia.org/wiki/Perl_Compatible_Regular_Expressions
--
Aura
More information about the BRLTTY
mailing list