Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
RegEx
Message
De
23/10/2012 11:17:41
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Re: RegEx
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01555501
Message ID:
01555551
Vues:
31
>>>Hi Gregory,
>>>
>>>I've run that code, but it doesn't do what I need. I want to replace the numbers with X, e.g. the resulting string should be
>>>'abcXXXXXXXXXXXXXXXXfd'
>>
>>Shouldn't be difficult, use option (2) slightly altered
>>
>So, do I understand correctly it's not easy with replace? E.g. I've tried:

You're mixing things - see my other reply - and read and digest the pages I pointed to


>
>if( m.loRegExp.Test(m.lcString) )
>   ? 'old: ', m.lcString 
>   lcString = m.loRegExp.Replace(m.lcString, '$1X{16}$3')
>   
>   ? 'new: ', m.lcString 
>endif
>
>but that converted the string into X{16}. I guess I can use 16X instead.
>
>>>>&& 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]
>>
>>
>>
>> s = m.match.Submatches[0] + repl('X', len( m.match.Submatches[1] )) + m.match.Submatches[2]
>>
>>
>>
>>>> lcString = stuff(m.lcString, m.match.FirstIndex+1, m.match.Length, m.s)
>>>>
>>>>
>>>>endfor
>>>>? 'new: ', m.lcString
>>>>
Gregory
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform