大神们我的代码如下:
String fileName ="F:\\py1\\wxprint.txt";
FileReader fileReader = new FileReader(fileName);
BufferedReader bufferedReader = new BufferedReader(fileReader);
System.out.println("字符集:"+fileReader.getEncoding());
String line =bufferedReader.readLine();
while (line!=null) {
System.out.println(line);
// List lines = new ArrayList();
System.out.println("==========");
s.setThistime(theTime);
//compile("")实在不知道怎末填了
Matcher matcher = Pattern.compile("").matcher(line);
//compile("") 里面写过: Pattern.compile("(?<=,'Text':')[\S]+?(?=',)").matcher(line);匹配不到
打印结果如下:
要匹配的记事本中的部分内容如下:
(注:记事本处显示的内容目前不是完全的json,不好解析,所以想用正则试试)
小弟想要匹配到如红框处所有'Text':后面的文字,还望正则大神们教教小弟,感激不尽。
(此为按照qiangchen1990大佬教的结果,还望大佬再交一下)
部分文本如下:
{'StatusNotifyCode': 0, 'ActualNickName': '多多', 'MsgId': '4750673808156304087', 'Type': 'Text', 'AppMsgType': 0, 'FileSize': '', 'SubMsgType': 0, 'HasProductId': 0, 'ToUserName': '@@bff166403f4a632e8315351ca040ce77f413deee515ebe7c37aed744a1413b5e', 'ActualUserName': '@a595384fe0c1c6c3aea42fe54aef15c1', 'IsAt': False, 'AppInfo': {'Type': 0, 'AppID': ''}, 'EncryFileName': '', 'User': , 'PYQuanPin': ''}>, 'Sex': 0, 'MemberList': , 'PYQuanPin': ''}>, , 'PYQuanPin': ''}>]>, 'City': '', 'Signature': '', 'HeadImgUpdateFlag': 1, 'AttrStatus': 0}>, 'ForwardFlag': 0, 'ImgHeight': 0, 'Url': '', 'FromUserName': '@a595384fe0c1c6c3aea42fe54aef15c1', 'FileName': '', 'MsgType': 1, 'VoiceLength': 0, 'Content': '问问', 'RecommendInfo': {'OpCode': 0, 'Province': '', 'VerifyFlag': 0, 'NickName': '', 'AttrStatus': 0, 'Content': '', 'UserName': '', 'Alias': '', 'Sex': 0, 'Scene': 0, 'City': '', 'Signature': '', 'Ticket': '', 'QQNum': 0}, 'Status': 3, 'MediaId': '', 'Text': '问问', 'ImgStatus': 1, 'ImgWidth': 0, 'PlayLength': 0, 'CreateTime': 1566271903, 'NewMsgId': 4750673808156304087, 'Ticket': '', 'StatusNotifyUserName': '', 'OriContent': ''}