Re: Regexes: How to handle escaped characters

2007-05-18 Thread Torsten Bronger
Hallöchen! Charles Sanders writes: > Torsten Bronger wrote: > > [...] > Example string: u"Hollo", escaped positions: [4]. Thus, the second "o" is escaped and must not be found be the regexp searches. Instead of re.search, I call the function guarded_search(pattern,

Re: Regexes: How to handle escaped characters

2007-05-18 Thread Charles Sanders
Torsten Bronger wrote: > Hallöchen! [...] >>> >>> Example string: u"Hollo", escaped positions: [4]. Thus, the >>> second "o" is escaped and must not be found be the regexp >>> searches. >>> >>> Instead of re.search, I call the function guarded_search(pattern, >>> text, offset) which takes care of

Re: Regexes: How to handle escaped characters

2007-05-18 Thread Torsten Bronger
Hallöchen! John Machin writes: > On May 18, 6:00 am, Torsten Bronger <[EMAIL PROTECTED]> > wrote: > >> [...] >> >> Example string: u"Hollo", escaped positions: [4]. Thus, the >> second "o" is escaped and must not be found be the regexp >> searches. >> >> Instead of re.search, I call the function

Re: Regexes: How to handle escaped characters

2007-05-17 Thread John Machin
On May 18, 9:46 am, Paul McGuire <[EMAIL PROTECTED]> wrote: > On May 17, 6:12 pm, John Machin <[EMAIL PROTECTED]> wrote: > > > Note: "must not be *part of* any match" [my emphasis] > > > > While we're waiting for clarification from the OP, there's a chicken- > > and-egg thought that's been nagging

Re: Regexes: How to handle escaped characters

2007-05-17 Thread Paul McGuire
On May 17, 6:12 pm, John Machin <[EMAIL PROTECTED]> wrote: > > Note: "must not be *part of* any match" [my emphasis] > Ooops, my bad. See this version: from pyparsing import Regex,ParseException,col,lineno,getTokensEndLoc # fake (and inefficient) version of any if not yet upgraded to Py2.5 any =

Re: Regexes: How to handle escaped characters

2007-05-17 Thread John Machin
On May 18, 8:16 am, Paul McGuire <[EMAIL PROTECTED]> wrote: > On May 17, 4:06 pm, John Machin <[EMAIL PROTECTED]> wrote: > > > > > On May 18, 6:00 am, Torsten Bronger <[EMAIL PROTECTED]> > > wrote: > > > > Hallöchen! > > > > James Stroud writes: > > > > Torsten Bronger wrote: > > > > >> I need some

Re: Regexes: How to handle escaped characters

2007-05-17 Thread Paul McGuire
On May 17, 4:06 pm, John Machin <[EMAIL PROTECTED]> wrote: > On May 18, 6:00 am, Torsten Bronger <[EMAIL PROTECTED]> > wrote: > > > > > > > Hallöchen! > > > James Stroud writes: > > > Torsten Bronger wrote: > > > >> I need some help with finding matches in a string that has some > > >> characters w

Re: Regexes: How to handle escaped characters

2007-05-17 Thread John Machin
On May 18, 6:50 am, James Stroud <[EMAIL PROTECTED]> wrote: > def guarded_search(rgx, astring, escaped): >m = re.search(rgx, astring) >if m: > s = m.start() > e = m.end() > for i in escaped: >if s <= i <= e: Did you mean to write if s <= i < e: ? > m =

Re: Regexes: How to handle escaped characters

2007-05-17 Thread John Machin
On May 18, 6:00 am, Torsten Bronger <[EMAIL PROTECTED]> wrote: > Hallöchen! > > James Stroud writes: > > Torsten Bronger wrote: > > >> I need some help with finding matches in a string that has some > >> characters which are marked as escaped (in a separate list of > >> indices). Escaped means tha

Re: Regexes: How to handle escaped characters

2007-05-17 Thread James Stroud
Torsten Bronger wrote: > Hallöchen! > > James Stroud writes: > > >>Torsten Bronger wrote: >> >> >>>I need some help with finding matches in a string that has some >>>characters which are marked as escaped (in a separate list of >>>indices). Escaped means that they must not be part of any match.

Re: Regexes: How to handle escaped characters

2007-05-17 Thread Torsten Bronger
Hallöchen! James Stroud writes: > Torsten Bronger wrote: > >> I need some help with finding matches in a string that has some >> characters which are marked as escaped (in a separate list of >> indices). Escaped means that they must not be part of any match. >> >> [...] > > You should probably p

Re: Regexes: How to handle escaped characters

2007-05-17 Thread James Stroud
Torsten Bronger wrote: > Hallöchen! > > I need some help with finding matches in a string that has some > characters which are marked as escaped (in a separate list of > indices). Escaped means that they must not be part of any match. > > My current approach is to look for matches in substrings

Regexes: How to handle escaped characters

2007-05-17 Thread Torsten Bronger
Hallöchen! I need some help with finding matches in a string that has some characters which are marked as escaped (in a separate list of indices). Escaped means that they must not be part of any match. My current approach is to look for matches in substrings with the escaped characters as bounda