Usually, the .* is used as "skip everything after", maybe you can add $ at the end.Mor3bane wrote:Thanks fonpaolo - incidentally the "." at the end could be misconstrued as part of the RegExp example
...
It is currently April 20th, 2024, 3:22 am
parsing single expression trouble [Solved x3]
-
- Moderator
- Posts: 1387
- Joined: April 11th, 2013, 8:08 pm
- Location: Italy
Re: parsing single expression trouble
-
- Posts: 943
- Joined: May 7th, 2016, 7:32 am
Re: parsing single expression trouble
Cool! Thanks for explaining thatfonpaolo wrote:Usually, the .* is used as "skip everything after", maybe you can add $ at the end.
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.
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.
-
- Moderator
- Posts: 1387
- Joined: April 11th, 2013, 8:08 pm
- Location: Italy
-
- Posts: 943
- Joined: May 7th, 2016, 7:32 am
Re: parsing single expression trouble [Solved x3]
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
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
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.
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.
-
- Rainmeter Sage
- Posts: 16147
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: parsing single expression trouble
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.FreeRaider wrote:Code: Select all
(?siU)<dnam>(.*)\W+\s+(.*)\W+\s+\w+<\/dnam>
-
- Rainmeter Sage
- Posts: 16147
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: parsing single expression trouble
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).Mor3bane wrote:For every (.*) there will increment another StringIndex
Yes?
Well, seems to work that way in my first test.
-
- Posts: 943
- Joined: May 7th, 2016, 7:32 am
Re: parsing single expression trouble
Thanks for confirming balala,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).
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!
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.
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.
-
- Rainmeter Sage
- Posts: 16147
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: parsing single expression trouble
Right. Parsing the whole page very rarely is a good idea. Usually parsing the needed parts is a better one.Mor3bane wrote:one can request sepcific parts and not have to parse the whole page
Happy New Year to you too.