## The module "mstrrep" of the Mastrave modelling library

Daniele de Rigo

The file mstrrep.m is part of Mastrave.

Mastrave is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

Mastrave is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Mastrave. If not, see http://www.gnu.org/licenses/.

#### Function declaration

answer = mstrrep( txt , search , replace , overlap )



#### Description

Returns the string answer obtained modifying a given string txt by replacing all the occurrences of the substring search with the content of replace .

#### Input arguments


txt                      ::row_string::
text to be transformed

search                   ::row_string::
substring to search for

replace                  ::row_string::
substring to replace with

overlap                  ::binary::
flag indicating whether or not overlapped
occurrences of the  search  string are allowed

This function extends and disambiguates the strrep(.) function of the
standard library, enabling the explicit choice between the two behaviours
that are currently implemented in different computing environments:
if the  overlap  flag is set to a true value, even overlapped occurrences
of the  search  string are searched for and replaced.
Otherwise, overlapped matches are ignored.
The  overlap  input argument has not a default value in order to avoid
unexpected behaviours in some computing environments.  Please prefer this
function instead of the pre-defined strrep(.), when the portability cost is
higher than the computational cost.



#### Example of usage


strrep(   'abbbbba'  ,  'bb'  ,  '.'  )
mstrrep(  'abbbbba'  ,  'bb'  ,  '.'  , 0 )
mstrrep(  'abbbbba'  ,  'bb'  ,  '.'  , 1 )

strrep(   'abcbcbcba'  ,  'bcb'  ,  '.'  )
mstrrep(  'abcbcbcba'  ,  'bcb'  ,  '.'  , 0 )
mstrrep(  'abcbcbcba'  ,  'bcb'  ,  '.'  , 1 )

strrep(   'abcbcbcba'  ,  'bcb'  ,  '_.-*'  )
mstrrep(  'abcbcbcba'  ,  'bcb'  ,  '_.-*'  , 0 )
mstrrep(  'abcbcbcba'  ,  'bcb'  ,  '_.-*'  , 1 )


version: 0.1.6

#### Support

The Mastrave modelling library is committed to provide reusable and general - but also robust and scalable - modules for research modellers dealing with computational science.  You can help the Mastrave project by providing feedbacks on unexpected behaviours of this module.  Despite all efforts, all of us - either developers or users - (should) know that errors are unavoidable.  However, the free software paradigm successfully highlights that scientific knowledge freedom also implies an impressive opportunity for collectively evolve the tools and ideas upon which our daily work is based.  Reporting a problem that you found using Mastrave may help the developer team to find a possible bug.  Please, be aware that Mastrave is entirely based on voluntary efforts: in order for your help to be as effective as possible, please read carefully the section on reporting problems.  Thank you for your collaboration.

Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 Daniele de Rigo