Solved

how to split this type of line?

Posted on 2016-10-24
5
120 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
[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
5 Comments
 
LVL 70

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

Industry Leaders: 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

Synchronize a new Active Directory domain with an existing Office 365 tenant
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.
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…
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…

691 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