Re: splitting perl-style find/replace regexp using python

2007-03-21 Thread John Pye
Thanks all for your suggestions on this. The 'splitter' idea was particularly good, not something I'd thought of. Sorry for my late reply. -- http://mail.python.org/mailman/listinfo/python-list

Re: splitting perl-style find/replace regexp using python

2007-03-01 Thread Peter Otten
John Pye wrote: > Is there an easy and general way that I can split these perl-style > find-and-replace expressions into something I can use with Python, eg > re.sub('search','replace',str) ? Another candidate: >>> re.compile(r"(?:/((?:\\.|[^/])*))").findall(r"/abc\\/def\/ghi//jkl") ['abc',

Re: splitting perl-style find/replace regexp using python

2007-03-01 Thread Peter Otten
James Stroud wrote: > Yes, this would be a case of the expression (left side) ending with a > "\" as I mentioned above. Sorry for not tracking the context. Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: splitting perl-style find/replace regexp using python

2007-03-01 Thread James Stroud
Peter Otten wrote: > James Stroud wrote: > >> James Stroud wrote: >>> John Pye wrote: Hi all I have a file with a bunch of perl regular expressions like so: /(^|[\s\(])\*([^ ].*?[^ ])\*([\s\)\.\,\:\;\!\?]|$)/$1'''$2'''$3/ # bold /(^|[\s\(])\_\_([^ ].*?[^ ])\_\_([

Re: splitting perl-style find/replace regexp using python

2007-03-01 Thread Peter Otten
James Stroud wrote: > James Stroud wrote: >> John Pye wrote: >>> Hi all >>> >>> I have a file with a bunch of perl regular expressions like so: >>> >>> /(^|[\s\(])\*([^ ].*?[^ ])\*([\s\)\.\,\:\;\!\?]|$)/$1'''$2'''$3/ # >>> bold >>> /(^|[\s\(])\_\_([^ ].*?[^ ])\_\_([\s\)\.\,\:\;\!\?]|$)/$1''$2<\/ >

Re: splitting perl-style find/replace regexp using python

2007-03-01 Thread James Stroud
James Stroud wrote: > John Pye wrote: >> Hi all >> >> I have a file with a bunch of perl regular expressions like so: >> >> /(^|[\s\(])\*([^ ].*?[^ ])\*([\s\)\.\,\:\;\!\?]|$)/$1'''$2'''$3/ # >> bold >> /(^|[\s\(])\_\_([^ ].*?[^ ])\_\_([\s\)\.\,\:\;\!\?]|$)/$1''$2<\/ >> b>''$3/ # italic bold >> /(^|

Re: splitting perl-style find/replace regexp using python

2007-03-01 Thread Peter Otten
John Pye wrote: > I have a file with a bunch of perl regular expressions like so: > > /(^|[\s\(])\*([^ ].*?[^ ])\*([\s\)\.\,\:\;\!\?]|$)/$1'''$2'''$3/ # > bold > /(^|[\s\(])\_\_([^ ].*?[^ ])\_\_([\s\)\.\,\:\;\!\?]|$)/$1''$2<\/ > b>''$3/ # italic bold > /(^|[\s\(])\_([^ ].*?[^ ])\_([\s\)\.\,\:\;\!

Re: splitting perl-style find/replace regexp using python

2007-03-01 Thread James Stroud
John Pye wrote: > Hi all > > I have a file with a bunch of perl regular expressions like so: > > /(^|[\s\(])\*([^ ].*?[^ ])\*([\s\)\.\,\:\;\!\?]|$)/$1'''$2'''$3/ # > bold > /(^|[\s\(])\_\_([^ ].*?[^ ])\_\_([\s\)\.\,\:\;\!\?]|$)/$1''$2<\/ > b>''$3/ # italic bold > /(^|[\s\(])\_([^ ].*?[^ ])\_([\s\

splitting perl-style find/replace regexp using python

2007-03-01 Thread John Pye
Hi all I have a file with a bunch of perl regular expressions like so: /(^|[\s\(])\*([^ ].*?[^ ])\*([\s\)\.\,\:\;\!\?]|$)/$1'''$2'''$3/ # bold /(^|[\s\(])\_\_([^ ].*?[^ ])\_\_([\s\)\.\,\:\;\!\?]|$)/$1''$2<\/ b>''$3/ # italic bold /(^|[\s\(])\_([^ ].*?[^ ])\_([\s\)\.\,\:\;\!\?]|$)/$1''$2''$3/ # it