如何通过正则表达式来匹配类似环境的shell兼容变量赋值(How to match environment-like shell-compatible variable assignment by regex)
我需要匹配这样的东西。 格式与centos中的/etc/locale.conf相同
LANG="en_US.UTF-8" LANG=en_US.UTF-8 LANG='en_US.UTF-8'比赛结束后,需要提取“LANG”和“en_US.UTF-8”
I need to match something like this. format is the same with /etc/locale.conf at centos
LANG="en_US.UTF-8" LANG=en_US.UTF-8 LANG='en_US.UTF-8'After match, need extract "LANG" and "en_US.UTF-8"
最满意答案
尝试:
^(\w+)=['"]?(.+?)['"]?$您可能需要根据您的要求玩弄键/值的字符。
在这里看到它的行动
Try:
^(\w+)=['"]?(.+?)['"]?$You may want to play with the character(s) of the key/value, depending on your requirements.
See it in action here
更多推荐
发布评论