如题,想把一个字符串分割成先要的部分:
STRING="change; alter[AAA; BBB; CCC]; modify; modification"
rtn_range = ("change","alter[AAA; BBB; CCC]", "modify", "modification")中间隔中括号比较烦人,麻烦各位高手了!!
STRING="change; alter[AAA; BBB; CCC]; modify; modification"
rtn_range = ("change","alter[AAA; BBB; CCC]", "modify", "modification")中间隔中括号比较烦人,麻烦各位高手了!!
String str = "change; alter[AAA; BBB; CCC]; modify; modification";
String[] tmp = str.split("(?<!.{0,100}\\[[^]]{0,100});");//数字自己调一下.适合自己的.python跑不过去.
error: look-behind requires fixed-width pattern
还有中括号前有时候是空格。
例如:
STRING="lose presence of mind; all in [into] a fluster; be nervous and flustered; be puzzled [perplexed; upset]; be thrown into confusion; AAA[CCC; DDD]; BBB"
麻烦再给加工加工,谢谢。
rtn_range=re.split(';\s*(?![^\[]+\])', STRING)
print rtn_range