Information générale
Catégorie:
COM/DCOM et OLE Automation
Hi all
I'm trying to get my head around using the RegExp object - so far it's OK but I've come across a problem I can't solve.
My pattern will always be a '*' followed by a word or words and ending with another '*' e.g. *Testing* or *Testing again*. The pattern could occur any number of times in a large chunk of text.
I want to replace the first '*' with '' and the second '*' with '' so the
end result will be Testing and Testing again
I guess the first question is if this is possible?'
If so I'm having trouble getting the pattern syntax correct e.g.
This will find me *Word* but not *Word word*
oReg.Pattern = "\*\w+\*"
I've tried different combinations of [a-zA-Z ] and \s to match a space too but no joy so far. Then of course, there's the problem of actually replacing the text. I'm guessing this can't be done with the Replace method and that I'll have to get a Match collection and parse that.
BTW - I'm well aware that I could do this in VFP fairly easily but I just want to try something new (well, it seemed like a good idea a couple of hours or so ago!).
Soooo - any regular expression, er, regulars out there? Or should I just go and have a quiet word with my good friends Jim Beam and Jack Daniels and continue the journey to the fabled land of Alcoholica (sorry, it's been a long day :)
Cheers
AJ
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement