This implementation fixes major limitations known and reported for years.
It can be used in Scilab >=5.5.0 on Windows, Linux and Mac OS.
FEATURES ADDED W.R.T. SCILAB NATIVE VERSION
-------------------------------------------
- in regular expression mode, all occurrences are replaced: fixes the bug 4276
- a 'ro' flag is added to still enable replacing only once in regexp mode.
- group replacement is supported: fixes the bug 9123
- multiple Pattern/Replace pairs can be replaced: fixes the bug 6145
- hypermatrix of text is accepted
- examples run with strsubt() are added
These extensions are fully compatible with the existing strsubst().
A related SEP (Scilab Enhancement Proposal) has been posted here:
http://bugzilla.scilab.org/show_bug.cgi?id=4276#c9
in order to include them in the Scilab distribution.
EXAMPLES OF USAGE: Enter "strsubst" without parameters
------------------------------------------------------
-->strsubst()
>> sc = ['Hello' 'Hólà' 'ALLO' 'Γεια σας'];
// Literal substitution. Unicode chars supported:
>> strsubst(sc, "l", "L")
!HeLLo HóLà ALLO Γεια σας !
// NEW: with matrices of Patterns and respective Replacements:
>> strsubst(sc, ['l' 'α'], ['L' 'A'])
!HeLLo HóLà ALLO ΓειA σAς !
// Regular expression (regexp),
// "ro"= Replace Once: only the first match is replaced:
>> strsubst('abcABCabc', '/[^^]a/i', '*', "ro")
ab*BCabc
// NEW: Regexp, all occurrences replaced. /i =case insensitive. /imxs supported
>> strsubst(sc, "/(l+)/i", "é", "r")
!Heéo Hóéà AéO Γεια σας !
// NEW: Regular expressions with groups replacements:
>> strsubst(sc, "/(.?)(l+)/i", "$2$1", "r")
!Hlleo Hlóà LLAO Γεια σας !