DaLiMan

[SOLVED] StringRegExpReplace with wilcard

5 posts in this topic

#1 ·  Posted (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 by DaLiMan

Share this post


Link to post
Share on other sites



#3 ·  Posted (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 by DaLiMan

Share this post


Link to post
Share on other sites

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.

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