Dynamic operators in regular expressions

View: New views
2 Messages — Rating Filter:   Alert me  

Dynamic operators in regular expressions

by Robert Platt-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

It seems that Octave regexprep does not recognise the ${cmd}dynamic
expression operator available in Matlab, because the ${}was replaced
literally rather than a return value from the command. Probably this is
not sucha commonly used feature but it would be very useful for a
Matlab/Octave numerical toolbox we are developing...

Is this a known issue and could this feature be supported in future?

Rob
_______________________________________________
Help-octave mailing list
Help-octave@...
https://www.cae.wisc.edu/mailman/listinfo/help-octave

Re: Dynamic operators in regular expressions

by dbateman :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Robert Platt-2 wrote:
Hi,

It seems that Octave regexprep does not recognise the ${cmd}dynamic
expression operator available in Matlab, because the ${}was replaced
literally rather than a return value from the command. Probably this is
not sucha commonly used feature but it would be very useful for a
Matlab/Octave numerical toolbox we are developing...

Is this a known issue and could this feature be supported in future?

Rob
Firstly try using singly quoted strings for at least the pattern and replacement. That being said is the variable in the pattern or the replacement? The regexp function can return the tokens matched, and I think it was implemented to allow the the tokens to be used in the replacement string of regexprep and in fact regexprep example

regexprep("Bill Dunn",'(\w+) (\w+)','$2, $1')

seems to work correctly. Is it the presence of the {} that is the issue? Is this a documented matlab feature. Can you give a short example of the failing code, that works in matlab?

D.