DaLiMan Posted December 28, 2016 Share Posted December 28, 2016 (edited) Hi, I was trying to create a StringRegExpReplace which removes all lines in a string with a certain pattern. The problem is that the end of the line changes with every appearance. I just cant figure out how the RegExp function operates and look behind the normal text for a pattern. Here is what I came up with. This remove the pattern which is given, but I need the whole line to be removed. Now only the beginning is deleted. The line to be deleted is like this. (TEXT - DATE - PAGENUMBER) THIS IS MY STRING TO BE REMOVED - 02-12-16 - P.1 THIS IS MY STRING TO BE REMOVED - 02-12-16 - P.2 THIS IS MY STRING TO BE REMOVED - 02-12-16 - P.3 THIS IS MY STRING TO BE REMOVED - 02-12-16 - P.4 ETC... Local $sString2 = StringRegExpReplace($sString, "(THIS IS MY STRING TO BE REMOVED - )|(?<=HFDGRP)", "") Edited December 28, 2016 by DaLiMan Link to comment Share on other sites More sharing options...
jguinch Posted December 28, 2016 Share Posted December 28, 2016 Try this : StringRegExReplace($sString, "(?m)^THIS IS MY STRING TO BE REMOVED\V+(?:\R|$)", "") Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
DaLiMan Posted December 28, 2016 Author Share Posted December 28, 2016 (edited) Hi jguinch, Yes, this does the trick. Thank you. Now that it's working I see another problem.... I need the first occurence not to be removed. Is it also possible to start te RegExp from row 50? PS: Where did you get the AU3 cup? (See your avatar) Edited December 28, 2016 by DaLiMan Link to comment Share on other sites More sharing options...
jguinch Posted December 28, 2016 Share Posted December 28, 2016 Does you file contains only this kind of lines, or it contains some other text ? I found the bug here, some years ago : http://www.cafepress.com/autoit Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
DaLiMan Posted December 28, 2016 Author Share Posted December 28, 2016 Thanks for the link. I like the mug. I just might order one. The file contains info (numbers) very different from the headers.(Alphabetical) It's the headers that are being repeated. I found I just remove all headers and add a first line with the header I want just before I write it to a new file. So, all works out just fine. Thanks for your help. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now