>loRegExp = CREATEOBJECT("VBScript.Regexp") > >loRegExp.PATTERN = "(\D)(\d{16})(\D|$)" && search for non digit following by 16 digits > >loRegExp.IgnoreCase = .T. && In this case, IgnoreCase = false is sufficient > >loRegExp.GLOBAL = .T. > >lcString = 'abc1234567890123456fd' >lcString = 'abc1234567890123456' >?m.loRegExp.Test(m.lcString) >>
>&& With replace() > >&& if is optional >if( m.loRegExp.Test(m.lcString) ) > ? 'old: ', m.lcString > lcString = m.loRegExp.Replace(m.lcString, '$1$2X$3') > > ? 'new: ', m.lcString >endif >>
>&& or with Execute() >lcString = 'abc1234567890123456' > >matchesObj = m.loRegExp.Execute(m.lcString) > >? 'old: ', m.lcString > >for i = m.matchesObj.Count - 1 to 0 step -1 > match = m.matchesObj.item(m.i) > > > > ?match.Submatches.Count > ?match.Submatches[0] > ?match.Submatches[1] > ?match.Submatches[2] > > s = m.match.Submatches[0] + m.match.Submatches[1] + 'X' + match.Submatches[2] > lcString = stuff(m.lcString, m.match.FirstIndex+1, m.match.Length, m.s) > > >endfor >? 'new: ', m.lcString >Greg,