I would have to agree with the other posters that regular expressions are
probably not the right tool in this case. That being said, I found the
problem quite intiguing. I have found a way to accomplish it, but it
requires more than just one simple expression. You have to reverse the
input and then reverse the result for it to work. Here is the code:
Imports System.Text.RegularExpressions
Imports Microsoft.VisualBasic
Module Module1
Sub Main()
Dim re As New Regex("\b(?<a>\w+)\b ?(?=.*\b\k<a>\b.*)")
Dim sReplacment As String = ""
Dim sInput As String = "10 8 8 5 3 7 10 9 8 5"
Console.WriteLine(StrReverse(re.Replace(StrReverse (sInput),
sReplacment)))
Console.ReadLine()
End Sub
End Module
Maybe someone else can modify this to work using only a single expression.
Brian Davis
www.knowdotnet.com
"Schorschi" <Schorschi@DSLExtreme.COM> wrote in message
news:21027c56.0312151916.11b4e8d6@posting.google.c om...[color=blue]
> This one has got me bam-boz-ald! or however your spell it...
>
> I have a sequence of text for example, "One Two Three Four Three Two
> One Three", and I need a regular expression, if possible, to remove
> the duplicates, so I would end with a string, "One Two Three Four."
> 1, "One" was removed, 1, "Two" was removed, 2, "Three" are removed,
> and the single "Four" instance is untouched. If you notice, the first
> instance of each word, is already in proper sequence. So, removing
> the duplicates is done after the initial word is identified. Another
> example is "10 8 8 5 3 7 10 9 8 5", with the result as "10 8 5 3 7 9."
>
> Anyone try to do this before?[/color]