Scilab Home Page | Wiki | Bug Tracker | Forge | Mailing List Archives | Scilab Online Help | ATOMS
File : Details
Login with GitLab

strsubst() extended

extensions provided: All occurrences replaced; multiple Pattern/Replace pairs; groups replacement
(1417 downloads for this version - 1417 downloads for all versions)
Details
Version
1.0
Author
Samuel Gougeon
Maintainer
Samuel Gougeon
Category
License
Supported Scilab Version
5.4
Creation Date
December 14, 2013
Description
            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  Γεια σας  !

            
Files (1)
[7.01 kB]
Miscellaneous file
File defining strsubst() and its utilities.

* MAKE IT AVAILABLE in EVERY SESSION: Click here to see HOW TO


News (0)
Comments (0)
Leave a comment
You must register and log in before leaving a comment.
Login with GitLab
Email notifications
Send me email when this toolbox has changes, new files or a new release.
You must register and log in before setting up notifications.