user10790374
user10790374

Reputation:

regex for getting particular output from sentences in python

I have some sentences:

[1, 23] fun(): Error Code: 1230. fun doen't exist

Error Code: 1123. Unknown column 'hhh'

END: Error Code: 2134. database doen't exist 

Now my concern is i want to get output like

['Error Code: 1230. fun doesn't exist','Error Code: 1123. Unknown column 'hhh'','Error Code: 2134. database doen't exist ']

I use \sError\s this regex , but it didn't work , i do code in python

How to make a regex for it?

Upvotes: 1

Views: 63

Answers (1)

Wiktor Stribiżew
Wiktor Stribiżew

Reputation: 627469

You may use

re.findall(r'\bError Code.*', s)

Details

  • \b - a word boundary
  • Error Code - a literal substring
  • .* - the rest of the line.

See the regex demo.

Upvotes: 2

Related Questions