我正在使用Talend解析具有以下行类型的文件,我已经尝试了tFileInputDelimted组件来解析它,但是文本更接近"'""不工作
1, 0, 1, 73, 0, 'root.1', 'Root Asset', '{"site":{"6":1,"2":1},"core":{"6":1}}'
我需要以下格式输出。
1
0
1
73
0
root.1
Root Asset
{"site":{"6":1,"2":1},"core":{"6":1}}
已编辑:示例行
`90, 'Loader Menu', '', '<div class="arrowlistmenu">\r\n<h3 class="menuheader"><a href="index.php/component/ordersoncalendar">View Orders</a></h3>\r\n<div class="shrink_div"> </div>\r\n<h3 class="menuheader"><a href="index.php/component/reportmaster/?task=report_details">Time Sheets</a></h3>\r\n<div class="shrink_div"> </div>\r\n<h3 class="menuheader"><a href="index.php/component/availabilitycalendar?task=availability">Update Availability</a></h3>\r\n<div class="shrink_div"> </div>\r\n<h3 class="menuheader"><a href="index.php/component/workers?task=update_personal_info">Update Personal Information</a></h3>\r\n<div class="shrink_div"> </div>\r\n<h3 class="menuheader"><strong><a href="index.php/component/workers?task=ask_password_change">Change Password</a></strong></h3>\r\n<div class="shrink_div"> </div>\r\n</div>', 1, 'loader-menu-position', 0, '0000-00-00 00:00:00', '0000-00-00 00:00:00', '0000-00-00 00:00:00', 1, 'mod_custom', 2, 1, '{"prepare_content":"1","backgroundimage":"","layout":"_:default","moduleclass_sfx":"","cache":"1","cache_time":"900","cachemode":"static"}', 0, '*'`
和此行的预期输出是。
90
'Loader Menu'
''
'<div class="arrowlistmenu">\r\n<h3 class="menuheader"><a href="index.php/component/ordersoncalendar">View Orders</a></h3>\r\n<div class="shrink_div"> </div>\r\n<h3 class="menuheader"><a href="index.php/component/reportmaster/?task=report_details">Time Sheets</a></h3>\r\n<div class="shrink_div"> </div>\r\n<h3 class="menuheader"><a href="index.php/component/availabilitycalendar?task=availability">Update Availability</a></h3>\r\n<div class="shrink_div"> </div>\r\n<h3 class="menuheader"><a href="index.php/component/workers?task=update_personal_info">Update Personal Information</a></h3>\r\n<div class="shrink_div"> </div>\r\n<h3 class="menuheader"><strong><a href="index.php/component/workers?task=ask_password_change">Change Password</a></strong></h3>\r\n<div class="shrink_div"> </div>\r\n</div>'
1
'loader-menu-position'
0
'0000-00-00 00:00:00'
'0000-00-00 00:00:00'
'0000-00-00 00:00:00'
1
'mod_custom'
2
1
'{"prepare_content":"1","backgroundimage":"","layout":"_:default","moduleclass_sfx":"","cache":"1","cache_time":"900","cachemode":"static"}'
0
'*'
正如我所说的文件有数百万行,在这里放置所有行的格式是非常困难的,但至少我们得到一些可以在行上解析的东西,这也是可以接受的。 请建议我如何实现它,因为这个文件有数百万条记录。
答案 0 :(得分:2)
答案 1 :(得分:0)
好像它只包含字符串和整数。所以你可以做匹配。
Matcher m = Pattern.compile("'([^']*)'|(\\d+(?:\\.\\d+)?)").matcher(str);
while(m.find())
{
System.out.println(m.group(1));
System.out.println(m.group(2));
}