Solved

how to split this type of line?

Posted on 2016-10-24
5
56 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 68

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 15

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 13

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
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 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 …
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…

759 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now