正则表达式:如何匹配"最小的"文本匹配我的正则表达式?

时间:2017-04-04 13:56:20

标签: c# regex

我试图从文本中提取一些信息。

我目前检索的文字是某种星座,例如:

Aries Some random text
which is on multiple
lines and could content one
of the word above, as love for
example.
Love ★★★✩
Job ★★★✩
Energy ★★★✩
Libra Some random text
which is on multiple
lines and could content one
of the word above, as job for
example.
Love ★★★✩
Job ★★★✩
Energy ★★★✩
Taurus Some random text
which is on multiple
lines and could content one
of the word above, as energy for
example.
Love ★★★✩
Job ★★★★
Energy ★★★★

我目前使用此正则表达式检索一个给定符号的不同值:

Aries([\S\s]*)Love\s*([★✩]{1,4})\sJob\s*([★✩]{1,4})\sEnergy\s*([★✩]{1,4})

但是[\S\s]*基本上可以捕捉它所能做到的一切,基本上这与我在示例中给出的全文相符。

两种可能性:

  • 如何匹配"最小的"表达可能吗?
  • 如何获得多行上的所有文字而无需获得Love / Job / Energy标题+明星?

谢谢!!!

0 个答案:

没有答案