一个专注于大数据技术架构与应用分享的技术博客

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路径里边包含了":",要把这个排除掉,正则表达式可以这么用":(?![://])"

赞(0)
版权声明:本文采用知识共享 署名4.0国际许可协议 [BY-NC-SA] 进行授权
文章名称:《Scala正则匹配》
文章链接:https://macsishu.com/scala%e6%ad%a3%e5%88%99%e5%8c%b9%e9%85%8d
本站资源仅供个人学习交流,请于下载后24小时内删除,不允许用于商业用途,否则法律问题自行承担。