Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/393.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 从Whatsapp文本文件获取信息的正则表达式_Java_Regex - Fatal编程技术网

Java 从Whatsapp文本文件获取信息的正则表达式

Java 从Whatsapp文本文件获取信息的正则表达式,java,regex,Java,Regex,我不知道如何创建正则表达式来从文本文件中提取不同的文本。我正在处理whatsapp聊天中包含消息详细信息的文本文件 考虑whatsapp聊天室文本文件中的以下数据: 25/12/2012 9:15 am: User1: Faith makes all things possible, Hope makes all things work, Love makes all things beautiful, May you have all the three for this Christmas.

我不知道如何创建正则表达式来从文本文件中提取不同的文本。我正在处理whatsapp聊天中包含消息详细信息的文本文件

考虑whatsapp聊天室文本文件中的以下数据:

25/12/2012 9:15 am: User1: Faith makes all things possible,
Hope makes all things work,
Love makes all things beautiful,
May you have all the three for this Christmas.
MERRY CHRISTMAS
01/01/2013 12:03 am: User1: <message>.
04/08/2013 10:54 am: User2: Happy Friendship day
13/10/2013 11:57 am: User1:<message>
<message continues>
<message continues>
30/12/2013 10:07 pm: User3:<message>
30/12/2013 11:12 pm: User4: Same to you

提前感谢您的帮助

我想你在找这个正则表达式

(\d{2}\/\d{2}\/\d{4})\s(\d(?:\d)?:\d{2} [ap]m):\s([^:]*):(.*?)(?=\s*\d{2}\/|$)
Java正则表达式是

"(?s)(\\d{2}/\\d{2}/\\d{4})\\s(\\d(?:\\d)?:\\d{2} [ap]m):\\s([^:]*):(.*?)(?=\\s*\\d{2}/|$)"

你有没有尝试过创建所需的正则表达式?我有试过这样做:我有试过这样做:我有试过这样做:我有试过这样做:我有试过这样做:我有试过:我有试过:我有试过这样做:我有试过这样做:我有试过这样做:我有试过这样做:我有试过这样做::::::::::((([A-A-A-A-A-A-Za-z-z-1-1.3)0-1.3)0-1.3)0-1.3)0-9[0-9)0[1,1,1,1,1,1,1,1,1,1,1,1,2,1,2,2,2,2,2,2,2,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3)[0-9]{1,2},\\s[0-9]{1,4},\\s[0-9]{1,2}[:]{1}[0-9]{1,2}\\s[APM]{2})\\s-\\s(.*):\\s([\\s\\s]*)太棒了!下次请在你的问题中包含它,以便更好地理解你的尝试(以及为什么这种方法不起作用)。好的,我会记住它@昂克洛斯
"(?s)(\\d{2}/\\d{2}/\\d{4})\\s(\\d(?:\\d)?:\\d{2} [ap]m):\\s([^:]*):(.*?)(?=\\s*\\d{2}/|$)"