Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

how to split multiple lines delimiter :

Posted on 2016-10-21
8
Medium Priority
?
185 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 13

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
Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

 
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 2000 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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Ready to get certified? Check out some courses that help you prepare for third-party exams.
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

596 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