Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .