[Scilab-users] replacing sed command by regexp ?

philippe rouxph.22 at gmail.com
Wed Jun 29 11:34:26 CEST 2016


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
%<---%<---%<---%<---%<---%<---%<---%<---%<---%<---%<---%<---%<---%<--





More information about the users mailing list