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

  • SEARCH
  • Home
  • 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

Can I simply use if(myString == nil) For some reason a string that I
Is this function declaration in C#: void foo(string mystring) the same as this one
What's the best way of adding spaces between strings myString = string.Concat(a, ,b) or
I want do something like this: Result = 'MyString' in [string1, string2, string3, string4];
I have a string like this: string s = This is my string; I
I have a string in Bash: string="My string" How can I test if it
I have this java string: String bla = <my:string>invalid_content</my:string>; How can I replace the
myString = THIS THING CAN KISS MY BUTT. HERE ARE MORE SSS; myNewString =
Dim myString As String = 1234567890 Dim Part As String = Part = myString.Substring(2,
return mystring.replace(/&/g, &amp;).replace(/>/g, &gt;) .replace(/</g, &lt;).replace(//g, &quot;); The above is my code, and I

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.