doublequotes in regexp 1.5.2 - zope/externalmethod

Discussion in 'Python' started by Florian Konnertz, Jul 7, 2003.

  1. 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/:mad:_%~#=&\.\-\?\+\$,]+'
    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
    Florian Konnertz, Jul 7, 2003
    #1
    1. Advertising

  2. Florian Konnertz

    Ulrich Petri Guest

    "Florian Konnertz" <> schrieb im Newsbeitrag
    news:bed11r$ssr$05$-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
    Ulrich Petri, Jul 8, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Shane Hathaway
    Replies:
    2
    Views:
    325
    Michael Hudson
    Aug 29, 2003
  2. Greg Hurrell
    Replies:
    4
    Views:
    157
    James Edward Gray II
    Feb 14, 2007
  3. Mikel Lindsaar
    Replies:
    0
    Views:
    481
    Mikel Lindsaar
    Mar 31, 2008
  4. Joao Silva
    Replies:
    16
    Views:
    358
    7stud --
    Aug 21, 2009
  5. Uldis  Bojars
    Replies:
    2
    Views:
    190
    Janwillem Borleffs
    Dec 17, 2006
Loading...

Share This Page