It is currently March 28th, 2024, 9:28 pm

Substitute Problem

Get help with creating, editing & fixing problems with skins
User avatar
Codger
Posts: 97
Joined: May 29th, 2017, 3:16 pm

Substitute Problem

Post by Codger »

I have a fragment returned from webparser

Code: Select all

[MeasureLocation]
Measure=Plugin
Plugin=WebParser
URL=[MeasureWebParseLocation]
StringIndex=2
DecodeCharacterReference=1
RegExpSubstitute=1
Substitute="^\s+":""
As you can see it strips off the opening newline.
Well they seemed to have added a closing newline or bunch of spaces as well.
I can not figure out how to strip them or it away.
By removing the '^' it did the trick except it took all the spaces from within the text as well.
Bear in mind the string might also be empty.
I have enough trouble with RegExp, then add in the substitute variant and make it tricky and I'm lost.
Could really use a helping hand on this.
[hr][/hr][hr][/hr]
"If you are the smartest one in the room, you are in the wrong room."
User avatar
CyberTheWorm
Posts: 860
Joined: August 22nd, 2016, 11:32 pm
Location: Surrey, B.C., Canada

Re: Substitute Problem

Post by CyberTheWorm »

you will need to post at least the URL of the website you are trying to parse before we can help you.
The only source of knowledge is experience. Albert Einstein
Deviant Art Page
User avatar
Codger
Posts: 97
Joined: May 29th, 2017, 3:16 pm

Re: Substitute Problem

Post by Codger »

CyberTheWorm wrote:you will need to post at least the URL of the website you are trying to parse before we can help you.
Your wish...

This is the parser routine:

Code: Select all

[MeasureWebParseLocation]
Measure=Plugin
Plugin=WebParser
URL=#IPLocationSite#
RegExp="(?siU)<h1 id="heading">(.*)</h1>.*<td>City</td>.*<a class=".*" href=".*"></a>(.*)</td>.*</tr>.*<tr>.*<td data-loc=".*,.*">.*,.*</td>.*</tr>.*(?(?=.*<tr>.*<td>Postal).*<td>Postal Code</td>.*<td>(.*)</td>.*</tr>).*</table>"
DynamicVariables=1
UpdateRate=20
The url: http://ipinfo.io/

Thanks
[hr][/hr][hr][/hr]
"If you are the smartest one in the room, you are in the wrong room."
User avatar
FreeRaider
Posts: 826
Joined: November 20th, 2012, 11:58 pm

Re: Substitute Problem

Post by FreeRaider »

Try this:

Code: Select all

RegExp=(?siU)<h1 id="heading">\s+\b(.*)\s+</h1>.*<td>City</td>.*<a class=".*" href=".*"></a>\s+\b(.*)</td>.*</tr>.*<tr>.*<td data-loc=".*,.*">.*,.*</td>.*</tr>.*(?(?=.*<tr>.*<td>Postal).*<td>Postal Code</td>.*<td>(.*)</td>.*</tr>).*</table>
User avatar
Codger
Posts: 97
Joined: May 29th, 2017, 3:16 pm

Re: Substitute Problem

Post by Codger »

FreeRaider wrote:Try this:

Code: Select all

RegExp=(?siU)<h1 id="heading">\s+\b(.*)\s+</h1>.*<td>City</td>.*<a class=".*" href=".*"></a>\s+\b(.*)</td>.*</tr>.*<tr>.*<td data-loc=".*,.*">.*,.*</td>.*</tr>.*(?(?=.*<tr>.*<td>Postal).*<td>Postal Code</td>.*<td>(.*)</td>.*</tr>).*</table>
Didn't quite work, but gave me enough clues that once I understood the new bits I was able to make the final tweak.
Thank you very much.
[hr][/hr][hr][/hr]
"If you are the smartest one in the room, you are in the wrong room."
User avatar
FreeRaider
Posts: 826
Joined: November 20th, 2012, 11:58 pm

Re: Substitute Problem

Post by FreeRaider »

:thumbup:
Glad to make mistakes to help :rofl:
User avatar
Codger
Posts: 97
Joined: May 29th, 2017, 3:16 pm

Re: Substitute Problem

Post by Codger »

:D
FreeRaider wrote::thumbup:
Glad to make mistakes to help :rofl:
:D I learn more that way.
[hr][/hr][hr][/hr]
"If you are the smartest one in the room, you are in the wrong room."