Scala正则匹配

用正则匹配拿到下面的数据

{"tablename":"a.student", "s3_path":"s3n://bucketname/student/","delimiter":",","partitions":""},
{"tablename":"a.tearcher", "s3_path":"s3n://bucketname/teacher/","delimiter":",","partitions":""},
{"tablename":"a.class", "s3_path":"s3n://bucketname/class/","delimiter":",","partitions":""}

1、通过”,”分割取出三组数据,注意有个键值对的值刚好是”,”,要避免拿这个当分隔符,正则表达式为”,(?!\”,)”

2、通过”:”分割键值对的键和值,注意s3路径里边包含了”:”,要把这个排除掉,正则表达式可以这么用”:(?![://])”

【版权说明:仅允许非商业转载且请注明出处:Mac私塾 网址:http://macsishu.com】

发表评论

邮箱地址不会被公开。