help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Perl-like regexp support ?


From: David Bateman
Subject: Re: Perl-like regexp support ?
Date: Mon, 6 Dec 2004 16:12:54 +0100
User-agent: Mutt/1.4.1i

Pascal, 

Are you aware of the "regexp" command in octave-forge. It doesn't
quite have the interface you describe, but it is close...

Regards
David

According to Pascal A. Dupuis <address@hidden> (on 12/06/04):
> Hello,
> 
> I'm working on a project where data follows a very complicated path:
> generated from a scope reading as text file, then processed under
> octave to generate SQL commands, introduced in a database, then
> re-read from the database, reworked, and so on.
> 
> Each step is performed by some specific octave portion, but sometimes
> I need to alter directly the SQL file. At this stage I use Perl
> because the regexp support is invaluable at coping with all the
> potential problems. But this requires further octave<->perl steps.
> 
> I was wondering if would be possible to interface directly octave with
> a perl-like regexp engine ? There is a regexp() function in MatLab7, I
> would imagine a interface like:
> 
> function [status, ...] = regexp(target, regexp, switch)
> where -target is the user-defined string
>       -regexp is defined the perlish way
>       -switch are the perl switches like g (global), i
>       (case-insensitive), o (compile once) 
> with one output argument, it would return a status (match/no match)
> with more than one output argument, the first is a status (how many
> subexpr matched), the second one is the first subexpr, and so on. So:
> 
> Perl way:
> # search for the word 'values' in between two substrings. The first
> # match is made non-greedy to find the first occurence
>       if (/(.*?)(values)(.*)/gio) {
>               ($order, $keyword, $data) = ($1, $2, $3);       
>       }
> octave way:
> (status, order, keyword, data) = regexp(my_line, '(.*?)(values)(.*)',
> 'gio')
> 
> if (status > 0) ... endif
> 
> So, Perl $1 would become the second output arg, and so on.
> 
> According to Perl doc (perldoc perlembed), Perl has a C API and the
> problem is to write the right interface between octave internals and
> C.
> 
> I can help writing/debugging the stuff, anyone else interested ?
> 
> Pascal Dupuis
> 
> -- 
> Dr. ir. Pascal Dupuis
> K. U. Leuven, ESAT/ELECTA (formerly ELEN):  http://www.esat.kuleuven.ac.be/
> Kasteelpark Arenberg, 10; B-3001 Leuven-Heverlee, Belgium
> Tel. +32-16-32 10 21 -- Fax +32-16-32 19 85
> 
> 
> 
> -------------------------------------------------------------
> Octave is freely available under the terms of the GNU GPL.
> 
> Octave's home on the web:  http://www.octave.org
> How to fund new projects:  http://www.octave.org/funding.html
> Subscription information:  http://www.octave.org/archive.html
> -------------------------------------------------------------

-- 
David Bateman                                address@hidden
Motorola CRM                                 +33 1 69 35 48 04 (Ph) 
Parc Les Algorithmes, Commune de St Aubin    +33 1 69 35 77 01 (Fax) 
91193 Gif-Sur-Yvette FRANCE

The information contained in this communication has been classified as: 

[x] General Business Information 
[ ] Motorola Internal Use Only 
[ ] Motorola Confidential Proprietary



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]