Solved

how to split multiple lines delimiter :

Posted on 2016-10-21
8
119 Views
Last Modified: 2016-10-21
windows os
this is only a small exmaple about how to split this:

aida.akbari789@gmail.com:176.58.104.12:aida1380.1393
baran_booran1@yahoo.com:2.184.85.16:BARAN_3490217012b
erfanmansorirad@yahoo.com:87.107.202.187:110110110110er1382
kdvm910@gmail.com:79.130.174.6:evr2010$

Open in new window


Output:

176.58.104.12:aida1380.1393
2.184.85.16:BARAN_3490217012b
87.107.202.187:110110110110er1382
79.130.174.6:evr2010$
0
Comment
Question by:john lambert
  • 4
  • 3
8 Comments
 
LVL 40

Expert Comment

by:Subsun
ID: 41854567
Try using powerShell..
("aida.akbari789@gmail.com:176.58.104.12:aida1380.1393" -split ":","2")[1]

Open in new window

Split from file..
GC C:\Test.txt | %{($_ -split ":","2")[1]}

Open in new window

0
 
LVL 12

Expert Comment

by:Dustin Saunders
ID: 41854568
You have a couple of different options (I'll use Powershell).  For each line you can use a substring:

$string = "aida.akbari789@gmail.com:176.58.104.12:aida1380.1393"

$output = $string.Substring($string.IndexOf(':')+1)

Write-Host $output

Open in new window


Or you could break it into an array:
$string = "aida.akbari789@gmail.com:176.58.104.12:aida1380.1393"

$array = $string.Split(':')

$output = $array[1] + ":" + $array[2]

Open in new window

1
 

Author Comment

by:john lambert
ID: 41854571
yes but cna u add Ouput.txt please?
thank you
0
Backup Solution for AWS

Read about how CloudBerry Backup fully integrates your backups with Amazon S3 and Amazon Glacier to provide military-grade encryption and dramatically cut storage costs on any platform.

 
LVL 40

Expert Comment

by:Subsun
ID: 41854574
Try..
GC C:\Test.txt | %{($_ -split ":","2")[1]} | Out-File C:\output.txt

Open in new window

1
 

Author Comment

by:john lambert
ID: 41854579
in fact my list look like this:

gfhghjh:ghjtilouijgffghgy@gmail.com:71.200.43.81:wsxcderfv123
server-ZkOficial:yanuari_la_bella@hotmail.com:186.88.91.191:uewyK4Tk2MARkwb2
JesusEnrique:jesus_enriquest@hotmail.com:189.132.59.13:DxXp8kTUyMA1fsCZ
LUISA:luisita_crazul@hotmail.com:187.242.244.123:PUMITAS20

Open in new window


Output.txt
IP:pass
0
 
LVL 40

Accepted Solution

by:
Subsun earned 500 total points
ID: 41854587
Try following and see if it works for you..
GC C:\Test.txt | %{($_ -split ".com:","2")[1]} | Out-File C:\output.txt

Open in new window

1
 

Author Closing Comment

by:john lambert
ID: 41854593
thank you.......
0
 
LVL 40

Expert Comment

by:Subsun
ID: 41854595
Other option is..
GC C:\Test.txt | %{($_ -split ":",3)[2]} | Out-File C:\output.txt

Open in new window

0

Featured Post

Free eBook: Backup on AWS

Everything you need to know about backup and disaster recovery with AWS, for FREE!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
A recent project that involved parsing Tableau Desktop and Server log files to extract reusable user queries for use in other systems. I chose to use PowerShell to gather the data, and SharePoint to present it...
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question