使用正则表达式解析多格式字符串

问题描述 投票:1回答:1

我正在尝试解析:

“-key -key-name-pair key = value key =” the values“ key ='the value'key my-key-gh = the-values my-key-gh =” the no-values“”]] >

我想返回以下字符串

  1. - 键
  2. - 密钥名称对
  3. 键=值
  4. key =“ the values”
  5. key ='the value'
  6. 我的密钥-GH =的值
  7. my-key-gh =“没有价值”
  8. 我已经尝试过此正则表达式:

(-([a-z])+)? |((\w)+=(\w)+)|((\w)+="(.*)")|((\w)+='(.*?)')|(\w+-\w+)+

我的表情怎么了?

我正在尝试解析:“ -key -key-name-pair key = value key =” the values“ key ='the value'key my-key-gh = the-values my-key-gh =” no-values“”“我希望以下字符串返回-key -key -...

python regex
1个回答
0
投票

您可以使用

© www.soinside.com 2019 - 2024. All rights reserved.