Jump to content

[SOLVED] StringRegExpReplace with wilcard


DaLiMan
 Share

Recommended Posts

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
Link to comment
Share on other sites

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
Link to comment
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.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...