1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
| function [varargout]= makeRegularFieldName(varargin)
%% transform an irregular field name in a regular field name
if nargin==0
error('error')
elseif nargin >1
error('error')
else
tmpChar=varargin{1};
if ~ischar(tmpChar)
error('error')
end
end
%%%%%%%%%%%%% first stage%%%%%%%%%%%%%%%%
%%%%%% replace accents %%%%%%%%%%%%%%%%%%
correspondanceTable={'ü','ue';
'ö','oe';
'ä','ae';
'ß','ss';
'é','e';
'è','e';
'ê','e';
'â','a';
'à','a';
'á','a';
'ô','o';
'ò','o';
'ó','o';
'û','u';
'É','E';
'È','E';
'Ê','E';
'Ä', 'A';
'Â', 'A';
'Á', 'A';
'À', 'A';
'Ü', 'U';
'Ú', 'U';
'Ù', 'U';
'Û', 'U';
'Ö', 'O';
'Ô', 'O';
'Ó', 'O';
'Ò', 'O';
'Î', 'I'};
scT=size(correspondanceTable);
for i=1:scT(1)
tmpChar=strrep(tmpChar,correspondanceTable{i,1},correspondanceTable{i,2});
end
%%%%%%%%%%%%%%%% eliminate unconventionnal signs %%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%% ,. : - _ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[StartTok, EndTok]=regexpi(tmpChar,'[a-z]+');
[StartTok2, EndTok2]=regexpi(tmpChar,'[0-9]+');
[StartTok3, EndTok3]=regexpi(tmpChar,'_');
TokS=horzcat(StartTok,StartTok2,StartTok3);
TokE=horzcat(EndTok,EndTok2,EndTok3);
TokS=sort(TokS,'ascend');
TokE=sort(TokE,'ascend');
newChar='';
for i=1:length(TokS)
newChar=horzcat(newChar,tmpChar(TokS(i):TokE(i)));
end
varargout{1}=newChar;
end |
Partager