我要分割一个字符串,需要创建一个List.So我必须使用下面的语法。 列出myList = new ArrayList(Arrays.asList(" Regex"));
我的输入字符串
1/6/2015 11:30:29 ERROR No connection.Verify the server is running. http://10.23.64.86:8080/-location/locations/
ErrorUrl : file:///C:/%20CODE/ddi/app/index.html#/TrainStatus
Error
at Scope.$digest (file:///C:/%20CODE/ddi/bower_components/angular/angular.js:12514:31)
at Scope.$apply (file:///C:/%20CODE/ddi/bower_components/angular/angular.js:12806:24)
at done (file:///C:/%20CODE/ddi/bower_components/angular/angular.js:8379:45),
1/6/2015 11:30:29 ERROR No connection.Verify the server is running. http://10.23.64.86:8080/-location/locations/
ErrorUrl : file:///C:/%20CODE/ddi/app/index.html#/TrainStatus
Error
at file:///C:/%20CODE/ddi/app/scripts/controllers/dTrainStatusSearchController.js:271:118
at file:///C:/%20CODE/ddi/bower_components/angular/angular.js:8120:11
at done (file:///C:/%20CODE/ddi/bower_components/angular/angular.js:8379:45)
我需要把它分成两个,如下面的
1/6/2015 11:30:29 ERROR No connection.Verify the server is running. http://10.23.64.86:8080/-location/locations/
ErrorUrl : file:///C:/%20CODE/ddi/app/index.html#/TrainStatus
Error
at Scope.$digest (file:///C:/%20CODE/ddi/bower_components/angular/angular.js:12514:31)
at Scope.$apply (file:///C:/%20CODE/ddi/bower_components/angular/angular.js:12806:24)
at done (file:///C:/%20CODE/ddi/bower_components/angular/angular.js:8379:45)
,
1/6/2015 11:30:29 ERROR No connection.Verify the server is running. http://10.23.64.86:8080/-location/locations/
ErrorUrl : file:///C:/%20CODE/ddi/app/index.html#/TrainStatus
Error
at file:///C:/%20CODE/ddi/app/scripts/controllers/dTrainStatusSearchController.js:271:118
at file:///C:/%20CODE/ddi/bower_components/angular/angular.js:8120:11
at done (file:///C:/%20CODE/ddi/bower_components/angular/angular.js:8379:45)
任何人都可以帮我构建精确的正则表达式来拆分上面的字符串并将其列为一个列表。 感谢
答案 0 :(得分:0)
如果这是您尝试拆分的唯一String
,这看起来很简单。
这样的内容适用于您在问题中提供的输入String
:
List<String> myList = Arrays.asList(yourString.split(","));
您可以使用http://regexpal.com/来帮助您。
答案 1 :(得分:0)