Shortening the username of the data arrived

Lanc1988

Well-known member
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:
Code:
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. :)
 
someone must know this..? I really need to find out how to shorten how long the username is
 
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:
Code:
        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
 
[VB]
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
[/VB]
 
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...
[VB]
Imports System.Text.RegularExpressions

Module VBSux

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

End Sub

End Module
[/VB]
 
Back
Top