[Scilab-users] replacing sed command by regexp ?

Clément David clement.david at scilab-enterprises.com
Fri Jul 8 14:37:18 CEST 2016


Hello Philippe,

About replacing "%foo_" to "foo_" in a file, I crafted an example using strsplit() and strcat() (see
attached) but it might be good to have an extended strsubst() that can output groups (\1 in your
regexp).

Do not hesitate to report a bug on that,

--
Clément

Le mercredi 29 juin 2016 à 11:34 +0200, philippe a écrit :
> Hi to all,
> 
> I need to remove some "%" characters  from help files that are generated
> with help_from_sci. The functions names start with "%" because these are
>  overloading functions , and I need to remove thoses "%" from xml ids in
> the help files (help files names are already changed).  To do this I've
> added the command :
> 
> unix('sed -i ''s/%\(.*\)_/\1_/g'' typea_op_typeb.xml')
> 
> to my help/en_US/builder_help.sce file, see details below. I suppose
> this could be a problem for users to build the toolbox on windows
> systems or even to publish the toolbox as an atoms module.
> 
> 
> I've already replaced all linux commands called with "unix(...)"  by
> their scilab equivalent (rm-> mmdelete, mv -> movefile, ...) except this
> call to "sed" . I know there is a  "regexp" function  but I'm not very
> comfortable with perl regular expressions, and I suppose I should
> combine it with "mgetl","mputl" and "strsubst"  to perform the good
> string substitutions .
> 
> Does some one has a simple way to do it ?
> 
> Philippe.
> 
> 
> %<---%<---%<---  help/en_US/builder_help.sce  %<---%<---%<---%<---%<--
> help_lang_dir = get_absolute_file_path('build_help.sce');
> help_from_sci('../macros/','../help/en_US','../demos/')
> printf('remove *percent* from xml id in help files \n')
> for fic=listfiles(help_lang_dir+'*.xml')'
>     unix('sed -i ''s/%\(.*\)_/\1_/g'' '+fic)
>     printf('%s\n',fic)
> end
> %<---%<---%<---%<---%<---%<---%<---%<---%<---%<---%<---%<---%<---%<--
> 
> 
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users
-------------- next part --------------
A non-text attachment was scrubbed...
Name: foo.sce
Type: application/x-scilab-sce
Size: 283 bytes
Desc: not available
URL: <https://lists.scilab.org/pipermail/users/attachments/20160708/f07b6658/attachment.bin>
-------------- next part --------------
this is a file containing
some %foo_ references and
also some %bar_ related
contents

And that's it !


More information about the users mailing list