[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

how to split this type of line?

Posted on 2016-10-24
5
Medium Priority
?
128 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 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

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

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

A brief introduction to what I consider to be the best editor for PowerShell.
There are times when we need to generate a report on the inbox rules, where users have set up forwarding externally in their mailbox. In this article, I will be sharing a script I wrote to generate the report in CSV format.
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 …

650 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