Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #78816
| Path | csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python@mrabarnett.plus.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.004 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'url:pypi': 0.03; 'modify': 0.07; 'transform': 0.07; 'string': 0.09; 'pointers': 0.09; 'subject:string': 0.09; 'subject:How': 0.10; 'accepting': 0.14; 'language.': 0.14; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'message- id:@mrabarnett.plus.com': 0.16; 'prefix,': 0.16; 'received:192.168.1.4': 0.16; 'regex,': 0.16; 'subject: \n ': 0.16; 'subject:possible': 0.16; 'thanks,': 0.17; 'wrote:': 0.18; 'library': 0.18; 'module': 0.19; 'machine': 0.22; '>>>': 0.22; 'input': 0.22; 'header:User-Agent:1': 0.23; 'question': 0.24; 'header:In-Reply-To:1': 0.27; 'point': 0.28; 'characters': 0.30; 'matching': 0.30; 'subject:other': 0.31; 'subject:that': 0.31; 'though.': 0.31; 'regular': 0.32; 'run': 0.32; 'url:python': 0.33; 'running': 0.33; 'not.': 0.33; 'actual': 0.34; "i'd": 0.34; 'point.': 0.35; 'but': 0.35; '(we': 0.36; "i'll": 0.36; 'possible': 0.36; 'url:org': 0.36; 'should': 0.36; 'implement': 0.38; 'to:addr:python-list': 0.38; 'does': 0.39; 'generating': 0.39; 'to:addr:python.org': 0.39; 'enough': 0.39; 'easy': 0.60; 'entire': 0.61; 'strictly': 0.61; "you're": 0.61; 'email addr:gmail.com': 0.63; 'such': 0.63; 'skip:n 10': 0.64; 'interest': 0.64; 'more': 0.64; 'determine': 0.67; 'manner': 0.72; 'subject:check': 0.84; 'state.': 0.95 |
| X-CM-Score | 0.00 |
| X-CNFS-Analysis | v=2.1 cv=HNxNF+dv c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=0Bzu9jTXAAAA:8 a=u9EReRu7m0cA:10 a=ihvODaAuJD4A:10 a=IkcTkHD0fZMA:10 a=EBOSESyhAAAA:8 a=pGLkceISAAAA:8 a=8AHkEIZyAAAA:8 a=OfkABY9Bqqz5cyjQ_t0A:9 a=QEXdDO2ut3YA:10 a=MSl-tDqOz04A:10 |
| X-AUTH | mrabarnett:2500 |
| Date | Wed, 08 Oct 2014 00:39:50 +0100 |
| From | MRAB <python@mrabarnett.plus.com> |
| User-Agent | Mozilla/5.0 (Windows NT 6.3; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 |
| MIME-Version | 1.0 |
| To | python-list@python.org |
| Subject | Re: How do I check if a string is a prefix of any possible other string that matches a given regex. |
| References | <dbf06cce-19ae-4859-9cc1-97f70d1bacfb@googlegroups.com> <mailman.14664.1412706991.18130.python-list@python.org> <8c47cee0-7fec-4fb7-b32a-ddac6fd7c247@googlegroups.com> |
| In-Reply-To | <8c47cee0-7fec-4fb7-b32a-ddac6fd7c247@googlegroups.com> |
| Content-Type | text/plain; charset=UTF-8; format=flowed |
| Content-Transfer-Encoding | 7bit |
| 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 | <https://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 | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.14668.1412725198.18130.python-list@python.org> (permalink) |
| Lines | 35 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1412725198 news.xs4all.nl 2925 [2001:888:2000:d::a6]:54066 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:78816 |
Show key headers only | View raw
On 2014-10-07 22:48, jonathan.slenders@gmail.com wrote: > >>> Logically, I'd think it should be possible by running the input >>> string against the state machine that the given regex describes, >>> and if at some point all the input characters are consumed, it's >>> a match. (We don't have to run the regex until the end.) But I >>> cannot find any library that does it... >> >> Strictly speaking, a DFA or NFA always consumes the entire input; >> the question of interest is whether it halts in an accepting state >> or not. >> >> It would be easy to transform a DFA or NFA in the manner that you >> want, though. For each non-accepting state, determine whether it >> has any transitions that lead in one or more steps to an accepting >> state. >> >> Modify the FSM so that each such state is also an accepting state. > > Thanks, I'll make every state of the FSM an accepting state. > > My use case is to implement autocompletion for a regular language. > So I think if the input is accepted by the FSM that I build, it's a > valid "prefix", and the autocompletion can be generated by looking > at which transitions are possible at that point. > > More pointers are welcome, but I think that I have enough to start > the implementation. > If you're not interested in generating an actual regex, but only in matching the prefix, then it sounds like you want "partial matching". The regex module supports that: https://pypi.python.org/pypi/regex
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
How do I check if a string is a prefix of any possible other string that matches a given regex. jonathan.slenders@gmail.com - 2014-10-07 09:15 -0700
Re: How do I check if a string is a prefix of any possible other string that matches a given regex. Joshua Landau <joshua@landau.ws> - 2014-10-07 18:01 +0100
Re: How do I check if a string is a prefix of any possible other string that matches a given regex. Ian Kelly <ian.g.kelly@gmail.com> - 2014-10-07 12:35 -0600
Re: How do I check if a string is a prefix of any possible other string that matches a given regex. jonathan.slenders@gmail.com - 2014-10-07 14:48 -0700
Re: How do I check if a string is a prefix of any possible other string that matches a given regex. MRAB <python@mrabarnett.plus.com> - 2014-10-08 00:39 +0100
Re: How do I check if a string is a prefix of any possible other string that matches a given regex. jonathan.slenders@gmail.com - 2014-10-08 01:48 -0700
Re: How do I check if a string is a prefix of any possible other string that matches a given regex. Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-10-09 10:24 +1300
csiph-web