It is currently April 20th, 2024, 3:22 am

parsing single expression trouble [Solved x3]

Get help with creating, editing & fixing problems with skins
User avatar
fonpaolo
Moderator
Posts: 1387
Joined: April 11th, 2013, 8:08 pm
Location: Italy

Re: parsing single expression trouble

Post by fonpaolo »

Mor3bane wrote:Thanks fonpaolo - incidentally the "." at the end could be misconstrued as part of the RegExp example :???: :)
...
Usually, the .* is used as "skip everything after", maybe you can add $ at the end.
User avatar
Mor3bane
Posts: 943
Joined: May 7th, 2016, 7:32 am

Re: parsing single expression trouble

Post by Mor3bane »

fonpaolo wrote:Usually, the .* is used as "skip everything after", maybe you can add $ at the end.
Cool! Thanks for explaining that :)
My DevArt Gallery

There are many ways to be different - there is only one way to be yourself - be amazing at it

The law of averages says what it means; even if you get everything right, you will get something wrong. Therefore; self managing error trapping initiates another set of averages - amongst the errors, some of them will not be errors, instead those instances will appear to be "luck". One cannot complain of the 'appearance' of 'infinite regress of causation', even if it does not have a predictable pattern, only that it requires luck to achieve.
User avatar
fonpaolo
Moderator
Posts: 1387
Joined: April 11th, 2013, 8:08 pm
Location: Italy

Re: parsing single expression trouble

Post by fonpaolo »

You're welcome.
...and happy New Year! :D
User avatar
Mor3bane
Posts: 943
Joined: May 7th, 2016, 7:32 am

Re: parsing single expression trouble [Solved x3]

Post by Mor3bane »

So I have gotten 3 suggestions I felt I could use in my case.

I will list all three:

1: "(?siU)<ut>(.*)</ut>.*<dnam>(.*), Australia</dnam>.*<hi>(.*)</hi>.*<low>(.*)</low>"

2: "(?siU)<ut>(.*)</ut>.*<dnam>(.*), (.*), (.*)</dnam>.*<hi>(.*)</hi>.*<low>(.*)</low>"

3: "(?siU)<ut>(.*)</ut>.*<dnam>(.*)\W+\s+(.*)\W+\s+\w+</dnam>.*<hi>(.*)</hi>.*<low>(.*)</low>"

#1 is specific to the output of my location - so not portable for sharing really.
#2 allows me to reference each string segment with a StringIndex
#3 breaks down the string leaving only the first segment for output, however this RegExp can also reference the second segment with an incremental StringIndex. This version leaves me with fewer StringIndexes to worry about (I think :) ).

Hope I got that right :D
My DevArt Gallery

There are many ways to be different - there is only one way to be yourself - be amazing at it

The law of averages says what it means; even if you get everything right, you will get something wrong. Therefore; self managing error trapping initiates another set of averages - amongst the errors, some of them will not be errors, instead those instances will appear to be "luck". One cannot complain of the 'appearance' of 'infinite regress of causation', even if it does not have a predictable pattern, only that it requires luck to achieve.
User avatar
balala
Rainmeter Sage
Posts: 16147
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: parsing single expression trouble

Post by balala »

FreeRaider wrote:

Code: Select all

(?siU)<dnam>(.*)\W+\s+(.*)\W+\s+\w+<\/dnam>
The slash (/) is not a reserved character in regular expressions. The reserved characters are: . ^, $, *, +, ?, (, ), [, {, \ and finally | (https://forum.rainmeter.net/viewtopic.php?p=124711#p124711). So, you don't have to escape it with a backslash in <\/dnam>. You can use the simple </dnam>. It'll work equally well.
User avatar
balala
Rainmeter Sage
Posts: 16147
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: parsing single expression trouble

Post by balala »

Mor3bane wrote:For every (.*) there will increment another StringIndex

Yes?

Well, seems to work that way in my first test.
You're right. For example in my RegExp=(?siU)<dnam>(.*), (.*), (.*)</dnam>, the measure with StringIndex=1 will relate to the first captured string, before the first comma (in this case Mount Isa), StringIndex=2 to the second captured string (QNS), while finally StringIndex=3 to the last captured string (Australia).
User avatar
Mor3bane
Posts: 943
Joined: May 7th, 2016, 7:32 am

Re: parsing single expression trouble

Post by Mor3bane »

balala wrote:You're right. For example in my RegExp=(?siU)<dnam>(.*), (.*), (.*)</dnam>, the measure with StringIndex=1 will relate to the first captured string, before the first comma (in this case Mount Isa), StringIndex=2 to the second captured string (QNS), while finally StringIndex=3 to the last captured string (Australia).
Thanks for confirming balala,
I keep heading back to the RegExp section of the manual, and realised with the HTML code for a page one can request sepcific parts and not have to parse the whole page as it would seem from some examples I have seen in other skin suites.
That made things much simpler, then breaking down selective syntax became simpler also.
As always, I appreciate the input from the more experienced Rainmeter hobbyists.

Happy New Year! :rosegift:
My DevArt Gallery

There are many ways to be different - there is only one way to be yourself - be amazing at it

The law of averages says what it means; even if you get everything right, you will get something wrong. Therefore; self managing error trapping initiates another set of averages - amongst the errors, some of them will not be errors, instead those instances will appear to be "luck". One cannot complain of the 'appearance' of 'infinite regress of causation', even if it does not have a predictable pattern, only that it requires luck to achieve.
User avatar
balala
Rainmeter Sage
Posts: 16147
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: parsing single expression trouble

Post by balala »

Mor3bane wrote:one can request sepcific parts and not have to parse the whole page
Right. Parsing the whole page very rarely is a good idea. Usually parsing the needed parts is a better one.
Happy New Year to you too.