It is currently April 26th, 2024, 7:58 pm

Using "Substitute" to remove a string with wildcards?

General topics related to Rainmeter.
Shiva
Posts: 5
Joined: January 30th, 2010, 3:10 pm

Using "Substitute" to remove a string with wildcards?

Post by Shiva »

Hi everyone,

I'm working on a Google News RSS reader skin. Every item is of the form "[Headline] - [Source]". I'd like to remove the " - [Source]" from the displayed text. Is there any way to do this using Substitute? Right now, I'm using a crude workaround (Substitute=" - CNN":""," - BBC News":"", etc...). If it's not possible with Substitute, is there another way? Using RegExp perhaps?

Thanks!
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Using "Substitute" to remove a string with wildcards?

Post by jsmorley »

Shiva wrote:Hi everyone,

I'm working on a Google News RSS reader skin. Every item is of the form "[Headline] - [Source]". I'd like to remove the " - [Source]" from the displayed text. Is there any way to do this using Substitute? Right now, I'm using a crude workaround (Substitute=" - CNN":""," - BBC News":"", etc...). If it's not possible with Substitute, is there another way? Using RegExp perhaps?

Thanks!
No way with Substitute short of the brute force approach you mentioned. With RegExp, you COULD use

<title>(.*) - .*

Which would return the title up to the first " - ", but you do run the risk of sometimes truncating the actual title information if it has that "space dash space" pattern in it.
Shiva
Posts: 5
Joined: January 30th, 2010, 3:10 pm

Re: Using "Substitute" to remove a string with wildcards?

Post by Shiva »

Thank you, worked like a charm!