Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a text file with the following information:

24.;128.32.;128,6;0.128.68.;128,1.;0.76.;;;;;0,1.;0.4.;0,2.;0.5.;0,4.;;;0.76.;128,;;;;;;;;172.30.1.1,172.30.1.228,

I need to remove all characters that appear before 172.30.1.1. For my file, it looks like this:

172.16.1.1,172.16.1.210,

I'm using the Poweshell to do this, but without success.

share|improve this question

1 Answer 1

A lot of it will depend on how consistent your data will be. There will be a multitude of methods. You could do it with a split:

$test = '24.;128.32.;128,6;0.128.68.;128,1.;0.76.;;;;;0,1.;0.4.;0,2.;0.5.;0,4.;;;0.76.;128,;;;;;;;;172.30.1.1,172.30.1.228,'
$partIWant = $test.Split(';')[$($test.Split(';').Count-1)]
$partIWant

You could use a regex as well:

$partIWant = $test -replace '.+(\d+.\d+\.\d+\.\d+\.\d+,\d+\.\d+\.\d+\.\d+,)', '$1'
$partIWant

You will need to pick the method that you want to use and craft it to the specific data that you will be working with.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.