Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > doublequotes in regexp 1.5.2 - zope/externalmethod

Reply
Thread Tools

doublequotes in regexp 1.5.2 - zope/externalmethod

 
 
Florian Konnertz
Guest
Posts: n/a
 
      07-07-2003
Hi,

I have to do a little script for an old zope website running on
python1.5.2 and have a regexp problem.

(for those who know zope: I have to change all stx links in a dtml doc
to html which is not done for any reason. It's an old zope (2.3.2)
python is 1.5.2 I tried with string.find, but i get a "string object
has no atribute 'find'" error - find is documented for python-1.5.2 :-/
So i guesses i have to use an External Method where i can use re.)

In this method i do a re.findall for the stx link, i tried with several
expressions, and one i need to use does not work which seems quite
strange to me. I tried to track this down to the simplest parts, but up
to now unsuccessfully so i need your help, please.
BTW in cli mode everything is fine if i start the same script with python1.5
Apparently it's a fault of the '"' character, the double quotes.

Here are the most simple pattern i tried, the double quotes quoted with
\ and not, in triple quotes and not etc. Everytime i add the double
quotes, my pattern fails. And my text definetly has several stx links in
it!!

pattern = r'"\S+'
pattern = r'''"\S+'''
pattern = r'''\"\S+'''

Everything without d.quotes is ok, i.e.
urlchars = r'[A-Za-z0-9/:@_%~#=&\.\-\?\+\$,]+'
urlendchar = r'[A-Za-z0-9/]'
url = r'["=]?((about|gopher|http|https|ftp|mailto|file):%s'
% urlendchar

this is the pattern i need:
link = r'(".+?"):%s' % (url)

which works fine on the cli.

TIA,
Florian


--
Florian Konnertz --- http://www.florian-konnertz.de
http://openspirit.homelinux.net/noowiki/FrontPage
ZWiki about all topics, especially consciousness research
and wisdom traditions

 
Reply With Quote
 
 
 
 
Ulrich Petri
Guest
Posts: n/a
 
      07-08-2003
"Florian Konnertz" <(E-Mail Removed)> schrieb im Newsbeitrag
news:bed11r$ssr$05$(E-Mail Removed)-online.com...
> Hi,
>
> I have to do a little script for an old zope website running on
> python1.5.2 and have a regexp problem.
>
> (for those who know zope: I have to change all stx links in a dtml doc
> to html which is not done for any reason. It's an old zope (2.3.2)
> python is 1.5.2 I tried with string.find, but i get a "string object
> has no atribute 'find'" error - find is documented for python-1.5.2 :-/
> So i guesses i have to use an External Method where i can use re.)
>

In python 1.5.2 you have to use:

import string

s="blah pattern blah"
pos = string.find(s, "pattern")


for Zope this would be:
<dtml-var "_.string.find(REQUEST['somevar'], 'somepattern')">

HTH

Ciao Ulrich


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
new RegExp().test() or just RegExp().test() Matěj Cepl Javascript 3 11-24-2009 02:41 PM
[regexp] How to convert string "/regexp/i" to /regexp/i - ? Joao Silva Ruby 16 08-21-2009 05:52 PM
Ruby 1.9 - ArgumentError: incompatible encoding regexp match(US-ASCII regexp with ISO-2022-JP string) Mikel Lindsaar Ruby 0 03-31-2008 10:27 AM
Programmatically turning a Regexp into an anchored Regexp Greg Hurrell Ruby 4 02-14-2007 06:56 PM
RegExp.exec() returns null when there is a match - a JavaScript RegExp bug? Uldis Bojars Javascript 2 12-17-2006 09:59 PM



Advertisments