Sign in to follow this  
Followers 0
crackmaster

How to replace the whole line that begin with...

5 posts in this topic

#1 ·  Posted (edited)

heh.. i need help again :P

Here is my problem: i can't figure it out how to replace whole line in file, instead of specified string. For example:

Winamp playlist contains this lines of text:

#EXTINF:428,02 - Void - Fuck The System (Skazi Remix)

D:\Qwerty\Void\02 - Void - Fuck The System (Skazi Remix).mp3

#EXTINF:464,02-void - hghway to hell-mycel

D:\Qwerty\Void\02-void_-_hghway_to_hell-mycel.mp3

I need 2 delete whole line that begin with "#EXTINF:", so at the end, file will contain only full paths, like this:

D:\Qwerty\Void\02 - Void - Fuck The System (Skazi Remix).mp3

D:\Qwerty\Void\02-void_-_hghway_to_hell-mycel.mp3

I have no idea how to work this out, and therefore my example looks like this :unsure:))

THankS.

Edited by crackmaster

Share this post


Link to post
Share on other sites

It's faster to read the whole file, delete it, modify the text using StringReplace, StringRegExpReplace etc. and write a new file with the modified text.

Share this post


Link to post
Share on other sites

It's faster to read the whole file, delete it, modify the text using StringReplace, StringRegExpReplace etc. and write a new file with the modified text.

Yes, but how? I can replace "#EXTINF:" string, but i need to delete every line that begin with "#EXTINF:".

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

So it's StringRegExpReplace counterpart is match anything that begins with #EXTINF:followed by anything till the end of the line right? lol

$sText = StringRegExpReplace($sText, '^#EXTINF:.*', '')

Not tested.

Edited by Authenticity

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Or to remove blank lines from output:

$sText = FileRead('test.txt')
$sText = StringRegExpReplace($sText, "#EXTINF.*[\n\r]", "")
msgbox(32, 'String', $sText)
Edited by Varian

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0