Shortening the username of the data arrived

Lanc1988

Contributor
Joined
Nov 27, 2003
Messages
508
I have made a chat project and it works pretty good, but I would like to shorten the username of when someone sends a message.. I have made it so when I send a message from my project it shows "<Username> Hi" but when I recieve a message it is really long.. here is an example:

<Lanc1988> Hi.
:Randy!~Randy@RivalIRC-372F10E.charter-stl.com PRIVMSG #Rssk :Hey.
<Lanc1988> How are you?
:Randy!~Randy@RivalIRC-372F10E.charter-stl.com PRIVMSG #Rssk :Good.


That is what I see.. and I would like to have it formatted to only show their username just like how I see mine.. here is the line of code I have in the DataArrival event that I think is where it can be changed:
Visual Basic:
Txtarrive.Text = String.Concat(Txtarrive.Text, vbNewLine, NewString)

If anyone needs any more info about my project to help me fix this problem just ask. Thanks. :)
 
use the regex
^[^!]+(?=!)

:Randy!~Randy@RivalIRC-372F10E.charter-stl.com PRIVMSG #Rssk :Hey.
will return
:Randy

I think the irc rfc says the username is seperated by the !
 
i dont really have any idea how to use the regex.. here is my DataArrival code if someone could please show me how to put that in, thanks:
Visual Basic:
        Dim A As Object
        Dim NewString As String
        Dim Character As Byte

        Sock.GetData(A)

        For Each Character In A
            NewString = String.Concat(NewString, Chr(Character))
        Next

        'After that, concat into txtArrive textBox
        Txtarrive.Text = String.Concat(Txtarrive.Text, vbNewLine, NewString)
Sock = the winsock
Txtarrive = textbox that shows sent and recieved messages
 
Visual Basic:
Imports System.Text.RegularExpressions

Module VBSux

    Sub Main()
        Dim sentence As String = ":Randy!~Randy@RivalIRC-372F10E.charter-stl.com PRIVMSG #Rssk :Hey."
        Dim name As String = Regex.Match(sentence, "^[^!]+(?=!)").Value
        Console.WriteLine(name)

    End Sub

End Module
 
ok, but since this is a chat room, this will only fix it for users who have that exact same name.. so how do I get it so it will fix all of them? or will this fix all of them?
 
shooting in the dark but...
Visual Basic:
Imports System.Text.RegularExpressions

Module VBSux

    Sub Main()
        Dim name As String = Regex.Match(Txtarrive.Txt, "^[^!]+(?=!)").Value
        Console.WriteLine(name)

    End Sub

End Module
 
Back
Top