Solved

how to split this type of line?

Posted on 2016-10-24
5
98 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
5 Comments
 
LVL 69

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

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

Set OWA language and time zone in Exchange for individuals, all users or per database.
Create and license users in Office 365 in bulk based on a CSV file. A step-by-step guide with PowerShell script examples.
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 if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …

830 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