1

I have a text file which contains the text

DATA collate UNKNOWN null,
or 
DATA collate UNKNOWN not null,

I need to delete collate and the unknown from the text file, I'm currently thinking the -replace with some form of regex is the way to go in some way shape or form, but I can't figure out how to keep the null or not null.

Also note that every line in the file does not contain collate and Unknown

0

1 Answer 1

2

I suppose UNKNOWN is a placeholder for any number of characters?

Then try

$result = $subject -creplace 'DATA collate .*?((?:not )?null,)', 'DATA $1'
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.