首页 > 解决方案 > Regex get part from "=" first occurence to left and rest to right

问题描述

I can't resolve this case:

hdfs://sandbox-hdp.hortonworks.com:8020/test/r/abc=1/day=1

Need to extract

/abc=1/day=1

So in this case we need to start from first occurence of = character and then get everything to the left till first occurence of / character and rest to right.

For now I only know how to get everything to right with this: =.*

标签: regex

解决方案


$ echo "hdfs://sandbox-hdp.hortonworks.com:8020/test/r/abc=1/day=1"  | grep -oE '[^/]+=.*'

推荐阅读