[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

how to split this type of line?

Posted on 2016-10-24
5
Medium Priority
?
130 Views
Last Modified: 2016-11-11
this is the line:

alex4ever31:*928A466A57546F7E1F1B930C2EBEAC5926826545:::juniorgg28@yahoo.com:::::2013-09-01 22:09:02:::::0:OK::0:0:0:0000-00-

Open in new window


first i wanna cut this:
alex4ever31:*928A466A57546F7E1F1B930C2EBEAC5926826545

Open in new window


then cut this
928A466A57546F7E1F1B930C2EBEAC5926826545:::juniorgg28@yahoo.com

Open in new window


thnak you
0
Comment
Question by:john lambert
4 Comments
 
LVL 71

Expert Comment

by:Qlemo
ID: 41858166
You want to have two strings with some parts being the same?
Can we rely on the number of colons and so on? Difficult to tell from a single line ...
0
 
LVL 16

Expert Comment

by:Walter Ritzel
ID: 41858452
Without taking much into consideration, you can do like this:
full_string = 'alex4ever31:*928A466A57546F7E1F1B930C2EBEAC5926826545:::juniorgg28@yahoo.com:::::2013-09-01 22:09:02:::::0:OK::0:0:0:0000-00-'
first_cut = full_string.split(':::')[0]
second_cut = full_string.split('*')[1].split(':::::')[0]
print(first_cut)
print(second_cut)

Open in new window


There better approaches for that, but then you would need to explain what you are trying to achieve so we can provide a more elegant answer.
0
 
LVL 14

Accepted Solution

by:
frankhelk earned 2000 total points
ID: 41858508
Given the format fit the colons as static, as Qlemo presumed, you could use a regex
^(.*?):(.*?):::(.*?):::

Open in new window

to filter out the needed components of the string.

The free tool Expresso from here filters the following capture groups:

Screen Snippet
Afterwards you could use the captured parts to build your new string with fresh colons in between, like

$1:$2
$2:::$3

Open in new window


which would give the requested results.
1
 

Author Closing Comment

by:john lambert
ID: 41883781
thank you problem solved!!!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
Previously, on our Nano Server Deployment series, we've created a new nano server image and deployed it on a physical server in part 2. Now we will go through configuration.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Loops Section Overview

829 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