regex to remove all text before a character

前端 未结 6 1027
孤独总比滥情好
孤独总比滥情好 2020-12-13 06:46

Is there an easy way to remove all chars before a \"_\"? For example, change 3.04_somename.jpg to somename.jpg.

Any suggestions for where t

6条回答
  •  情歌与酒
    2020-12-13 07:29

    no need to do a replacement. the regex will give you what u wanted directly:

    "(?<=_)[^_]*\.jpg"
    

    tested with grep:

     echo "3.04_somename.jpg"|grep -oP "(?<=_)[^_]*\.jpg"
    somename.jpg
    

提交回复
热议问题