On 25/06/2012 19:15, Ron Ganbar wrote:
Hi Wouter,
I tried this kinda thing for the regex strings:
regex =
re.compile('\\t+([-+]?\d+\.?\d*)\\t+([-+]?\d+\.?\d*)\\t+([-+]?\d+\.?\d*)\\t+([-+]?\d+\.?\d*)\\t+')

I'd recommend:

re.compile('[ \\t]+([-+]?\d+\.?\d*){4}[ \\t]+')

The {4} means the same expression has to match exactly 4 times. This makes the expression a bit more readable I think.

Otherwise, I would also recommend what Nathan's suggesting.

HTH,
    Wouter

Didn't help (though testing the string in pythonregex.com
<http://pythonregex.com> does show results).

If I did it wrong I'd love to know. Any other ideas welcome too.

Thanks!
Ron Ganbar
email: [email protected] <mailto:[email protected]>
tel: +44 (0)7968 007 309 [UK]
      +972 (0)54 255 9765 [Israel]
url: http://ronganbar.wordpress.com/



On 25 June 2012 21:05, Ron Ganbar <[email protected]
<mailto:[email protected]>> wrote:

    Hi Wouter,
    thanks. That's something I haven't tried.
    I'll have a look.



    Ron Ganbar
    email: [email protected] <mailto:[email protected]>
    tel: +44 (0)7968 007 309 <tel:%2B44%20%280%297968%20007%20309> [UK]
    +972 (0)54 255 9765 <tel:%2B972%20%280%2954%20255%209765> [Israel]
    url: http://ronganbar.wordpress.com/



    On 25 June 2012 20:15, Wouter Klouwen <[email protected]
    <mailto:[email protected]>> wrote:

        On 19/06/2012 08:28, Ron Ganbar wrote:

            The weird thing is that the code I have works perfectly when
            reading the
            text from a text file, just not when reading from paste.
            Really annoying
            to start and write it again from scratch. Plus, I would love
            to have
            learned from this script something useful about re.
            Any chance you can have another look?


        Your regexps look very strict. I would suggest to be more
        permissive in the amount and kind of whitespacing you allow
        between numbers.
        I would suggest:

        [:blank:]+  instead of \t

        Or if the Python regexps don't support he POSIX character
        classes, just [ \t]+.

        It's entirely possible that you're getting spaces in the pasted
        data instead of the tabs read from file.

        HTH,
            Wouter

        --
        Wouter Klouwen, Software Engineer
        The Foundry, 6th Floor, Comms Building, 48 Leicester Sq, London
        WC2H LT
        Tel: +442079686828 <tel:%2B442079686828> • Fax: +4420 79308906
        <tel:%2B4420%2079308906> • thefoundry.co.uk
        <http://thefoundry.co.uk>
        The Foundry Visionmongers Ltd • Reg.d in England and Wales No:
        4642027

        _________________________________________________
        Nuke-python mailing list
        Nuke-python@support.__thefoundry.co.uk
        <mailto:[email protected]>,
        http://forums.thefoundry.co.__uk/ <http://forums.thefoundry.co.uk/>
        http://support.thefoundry.co.__uk/cgi-bin/mailman/listinfo/__nuke-python
        <http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python>





_______________________________________________
Nuke-python mailing list
[email protected], http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python


--
Wouter Klouwen, Software Engineer
The Foundry, 6th Floor, Comms Building, 48 Leicester Sq, London WC2H LT
Tel: +442079686828 • Fax: +4420 79308906 • thefoundry.co.uk
The Foundry Visionmongers Ltd • Reg.d in England and Wales No: 4642027
_______________________________________________
Nuke-python mailing list
[email protected], http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python

Reply via email to