Author Topic: Need help with Results.RegEx  (Read 1660 times)

0 Members and 1 Guest are viewing this topic.

Telorast

  • $upporter
  • Jr. Member
  • *****
  • Posts: 28
  • Karma: 0
    • View Profile
Need help with Results.RegEx
« on: November 02, 2012, 10:07:00 AM »
I'm trying to get the computer to tell me the weather and wunderground returns a nice text string that I'm trying to use. But I'm not interested in the wind conditions so I'm trying to trim that bit off but I can't figure out how to get Results.RegEx to match properly.

To test it I wrote this macro that sets last result, try to match the wind part and then replace it with a space character:

Results.SetLastResult     Overcast in the morning, then mostly cloudy. Winds from the South at 15 to 20 km/h.
Results.RegEx               (Wind.*)
Results.Replace             {match.1} && " "
OSD.ShowText             {lastresult}

Wanted result: "Overcast in the morning, then mostly cloudy.  "
Seen result:     "Overcast in the morning, then mostly cloudy. Winds from the South at 15 to 20 km/h."

It doesn't work and I can't figure out why. Tried lots of expressions but nothing seems to match.

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Need help with Results.RegEx
« Reply #1 on: November 02, 2012, 11:40:29 AM »
Hi Telorast.

Welcome to the community and thank-you for your question.  I'm not 100% sure why your method is not working, but I can tell you the easier way to do it that works.

Instead of using two actions:

Code: [Select]
Results.RegEx...
Results.Replace...

use one action:

Code: [Select]
Results.RegExReplace    (Wind.*)
and leave the 2nd param blank.

I don't know all the possible strings that WUnder could return so I don't know if anything more sophisticated would be required to keep possibly useful information that comes after Wind... but this should get you on the right track.

Telorast

  • $upporter
  • Jr. Member
  • *****
  • Posts: 28
  • Karma: 0
    • View Profile
Re: Need help with Results.RegEx
« Reply #2 on: November 02, 2012, 09:16:23 PM »
Thanks, somehow the same expression matched in RegExReplace.