简体   繁体   English

Java-如何将irc消息解析为人类可读

[英]Java - How to parse irc message to human readable

I am creating an irc client in Java. 我正在用Java创建一个irc客户端。 It work fine but the message from the server is a bit "messed-up" for example :User1!webirc@1.9.com PRIVMSG #channel :test . 它工作正常,但是来自服务器的消息有点“混乱”,例如:User1!webirc@1.9.com PRIVMSG #channel :test So i wanna know how to parse the irc message to human readable? 所以我想知道如何将irc消息解析为人类可读? Here is a regex that i found ^(:(\\\\S+) )?(\\\\S+)( (?!:)(.+?))?( :(.+))?$ for irc message. 这是我发现^(:(\\\\S+) )?(\\\\S+)( (?!:)(.+?))?( :(.+))?$的正则表达式。

The IRC Protocol is documented here: https://tools.ietf.org/html/rfc2812 IRC协议记录在这里: https : //tools.ietf.org/html/rfc2812

2.3.1 Message format in Augmented BNF 2.3.1增强BNF中的消息格式

The protocol messages must be extracted from the contiguous stream of octets. 协议消息必须从连续的八位字节流中提取。 The current solution is to designate two characters, CR and LF, as message separators. 当前的解决方案是指定两个字符CR和LF作为消息分隔符。 Empty messages are silently ignored, which permits use of the sequence CR-LF between messages without extra problems. 空消息将被静默忽略,这允许在消息之间使用序列CR-LF,而不会带来额外的问题。

The extracted message is parsed into the components , and list of parameters (). 提取的消息被解析为components和参数列表()。

The Augmented BNF representation for this is:

message    =  [ ":" prefix SPACE ] command [ params ] crlf
prefix     =  servername / ( nickname [ [ "!" user ] "@" host ] )
command    =  1*letter / 3digit
params     =  *14( SPACE middle ) [ SPACE ":" trailing ]
           =/ 14( SPACE middle ) [ SPACE [ ":" ] trailing ]

nospcrlfcl =  %x01-09 / %x0B-0C / %x0E-1F / %x21-39 / %x3B-FF
                ; any octet except NUL, CR, LF, " " and ":"
middle     =  nospcrlfcl *( ":" / nospcrlfcl )
trailing   =  *( ":" / " " / nospcrlfcl )

SPACE      =  %x20        ; space character
crlf       =  %x0D %x0A   ; "carriage return" "linefeed"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Java中生成人类可读的唯一ID - how to generate human readable unique id in java 如何使Java属性文件易于阅读 - How to keep Java properties files human readable 如何在Java中以人类可读的格式显示时间? - How to show time in human readable format in Java? 如何在Java中将下划线转换成易于理解的名称? - How do I convert underscore into human-readable names in Java? 如何在 Java 中将 CamelCase 转换为人类可读的名称? - How do I convert CamelCase into human-readable names in Java? Java文件压缩(Hadoop DefaultCodec)-如何使其易于阅读? - File Compression in Java (Hadoop DefaultCodec) - how to make it human readable? 如何在Java源代码中存储密钥但不是人类可读的密钥 - How to store secret key in Java source but not human readable 在Java中是否可以解析存档库(.a)和.so(共享对象)文件的内容以检索人类可读的文本? - Is it possible in java to parse content of Archive libraries (.a), and .so (shared object) files to retrieve human readable text? 将字符串转换为人类可读日期(java / android) - Convert string to human readable date (java/android) Java中人类可读格式的SNMP EventTime - SNMP EventTime in Human Readable format in Java
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM