Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 426847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T19:31:13+00:00 2026-05-12T19:31:13+00:00

mystring = ’14| Preprocessor Frame Count Not Incrementing; Card: Motherboard, Port: 2|minor’ So I

  • 0

mystring = ’14| “Preprocessor Frame Count Not Incrementing; Card: Motherboard, Port: 2″|minor’

So I have 3 elements (id, message and level) divided by pipe (“|”). I want to get each element so I have written these little functions:

    def get_msg(i):
        x = i.split("|")
        return x[1].strip().replace('"','')

    def get_level(i):
        x = i.split("|")
        return x[2].strip()
 #testing
print get_msg(mystring ) # Missing Input PID,   PID: 20 : Port 4 of a static component
print get_level(mystring )# major

Right now it works well but I feel like this is not pythonic way to solve it, how could these 2 functions can be improved? Regular expression feels like fitting here but I’m very naive at it so couldn’t apply.

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T19:31:13+00:00Added an answer on May 12, 2026 at 7:31 pm
    class MyParser(object):
        def __init__(self, value):
            self.lst = value.split('|')
        def id(self):
            return self.lst[0]
        def level(self):
            return self.lst[2].strip()
        def message(self):
            return self.lst[1].strip(' "')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this in my code : NSString *myString = @; .... if (...)
i have a NSString object named as myString.i need to append a space in
Let's say that I have declared an NSString like this NSString *myString = [[NSString
String myString = OID.1.2.840.113549.1.9.2=Responsable: Fernando Martínez Coss, L=Cuauhtemoc, ST=Distrito Federal, C=MX, OID.2.5.4.17=06300, STREET=Av. Hidalgo
I'm using XDoclet to generate code: /** * @diff.special */ public String myString; Now
Possible Duplicate: What is the difference between NSString* mystring and NSString *mystring I believe
Possible Duplicate: What is the difference between NSString* mystring and NSString *mystring Should I
This is a sample .txt file: item1 item2 myString item3 item4 I created a
My program crashes as soon as a new MyString object is created. When the
I use the codes to access sqlite sqlite3_bind_text(statement,1,[myString UTF8String],-1,SQLITE_TRANSIENT); It works. But if myString

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.