Python Forum
Need help to extract particular string
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need help to extract particular string
#1
Hi,

I want to extract particular string in a file.suppose file contains the following string.

INFO 2019-02-19 20:59:56,178 - Process Start time : 2019-02-19 20:55:09.778793
INFO 2019-02-19 20:59:56,178 - Process End time : 2019-02-19 20:59:56.178893

Output should be like as below.

Output:
Process Start time : 2019-02-19 20:55:09.778793 Process End time : 2019-02-19 20:59:56.178893
I tried to achieve the output using below but not succeeded.

import re
    re.match("(.*)Process Start time(.*)", line):
        c= line.split("-")[3]
        print(c)
Could you please help me in advance
Reply


Messages In This Thread
Need help to extract particular string - by lokesh - Sep-04-2019, 05:35 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  extract substring from a string before a word !! evilcode1 3 572 Nov-08-2023, 12:18 AM
Last Post: evilcode1
  Extract a string between 2 words from a text file OscarBoots 2 1,892 Nov-02-2021, 08:50 AM
Last Post: ibreeden
  How to extract specific key value pair from string? aditi06 0 2,555 Apr-15-2021, 06:26 PM
Last Post: aditi06
Question How to extract multiple text from a string? chatguy 2 2,410 Feb-28-2021, 07:39 AM
Last Post: bowlofred
  Extract continuous numeric characters from a string in Python Robotguy 2 2,668 Jan-16-2021, 12:44 AM
Last Post: snippsat
  extract a dictionary from a string berc 4 2,888 Jul-30-2020, 06:58 AM
Last Post: berc
  Extract data from large string pzig98 1 2,146 Jul-20-2020, 12:39 AM
Last Post: Larz60+
  xml.etree.ElementTree extract string values matthias100 2 5,023 Jul-12-2020, 06:02 PM
Last Post: snippsat
  Extract email addresses from string and store them in a list oslosurfer 2 2,734 Nov-24-2019, 03:35 PM
Last Post: oslosurfer
  extract version in a string lokesh 2 2,190 Oct-09-2019, 05:49 AM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020