News:

HOT TIP! Exploring the commands packaged in VC's standard configurations is a great way to learn how to build your own. You can also clone a command as a starting point: just right-click and select "Clone" (or type Alt-C).

Main Menu

Need help with Results.RegEx

Started by Telorast, November 02, 2012, 10:07:00 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Telorast

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

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:

Results.RegEx...
Results.Replace...


use one action:

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

Thanks, somehow the same expression matched in RegExReplace.