function do_it() local RegExp, x, s RegExp = CreateObject('VBScript.RegExp') RegExp.IgnoreCase = FALSE RegExp.Global = TRUE RegExp.Pattern = '\.{2,}' s = '12.........34.................56.............' x = RegExp.Replace(s, '.') ?'<'+x+'>' s = '12 34 56 ' RegExp.Pattern = ' {2,}' x = RegExp.Replace(s, ' ') ?'<'+x+'>' && to remove trailing as well s = '12 34 56 ' RegExp.Pattern = ' {2,}' x = RegExp.Replace(s, ' ') RegExp.Pattern = ' $' x = RegExp.Replace(x, '') ?'<'+x+'>' && or all in one local RegExp1, RegExp2 RegExp1 = CreateObject('VBScript.RegExp') RegExp1.IgnoreCase = FALSE RegExp1.Global = TRUE RegExp1.Pattern = ' {2,}' RegExp2 = CreateObject('VBScript.RegExp') RegExp2.IgnoreCase = FALSE RegExp2.Global = TRUE RegExp2.Pattern = ' $' x = RegExp2.Replace(RegExp1.Replace(s, ' '), '') ?'<'+x+'>' endfunc>Hi Greg,
>a = '12......34...56...6..5.' >DO WHILE !EMPTY(OCCURS('..',a)) > a=STRTRAN(a,'..','.') >ENDDO &&!EMPTY(OCCURS('..',a)) >?a >>but I search for something without loop.
>> >>a = '12...34...56...' >>? StringSearchAndReplace(a, '..', '.') >> >>*------------------------------------------------------------------------------- >>function StringSearchAndReplace(Searched, SearchFor, ReplaceWith, IgnoreCase) >> >> local i, Offset, SearchForLength, ReplaceWithLength >> >> SearchForLength = len(SearchFor) >> ReplaceWithLength = len(ReplaceWith) >> Offset = 1 >> >> do case >> case IgnoreCase >> i = atc(SearchFor, substr(Searched, Offset)) >> do while !empty(i) >> i = i + Offset - 1 >> Searched = stuff(Searched, i, SearchForLength, ReplaceWith) >> Offset = Offset + ReplaceWithLength >> i = atc(SearchFor, substr(Searched, Offset)) >> enddo >> otherwise >> i = at(SearchFor, substr(Searched, Offset)) >> do while !empty(i) >> i = i + Offset - 1 >> Searched = stuff(Searched, i, SearchForLength, ReplaceWith) >> Offset = Offset + ReplaceWithLength >> i = at(SearchFor, substr(Searched, Offset)) >> enddo >> endcase >> >> return Searched >>endfunc >>*-------------------------------------------------------------------------- >>