0

I'm trying to extract some information from a text.

The text I currently retrieve is some kind of horoscope, with by example:

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 ★★★★

I've currently this regex to retrieve the differents values for one given sign:

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

but the [\S\s]*is basically catching everything it can, and basically this match the whole text I gave in example.

So two possibility:

  • How to match the "smallest" expression possible?
  • How to get the all the text on multiple lines without ALSO getting the Love/Job/Energy header+stars?

Thank you!!!

J4N
  • 19,480
  • 39
  • 187
  • 340

0 Answers0