Python String split using comma before a specific string

sameer shiva

How to split using comma before a specific string and maxsplit=1 using python regex? For Example here is a string: Speciality: "Aesthetic Medicine, Oncology" , Profession:"Physician (MD, DO, Resident)" I need to split this string at comma(,) right before "Profession".

ZiTAL

something like this?

#!/usr/bin/python2
# -*- coding: utf-8 -*-

import re

txt = 'Speciality: "Aesthetic Medicine, Oncology" , Profession: "Physician (MD, DO, Resident)"'

a = re.match('^(.*?),\s+(Profession:)(.*?)$', txt)

if(a):
#   print a.group(0)
    first = a.group(1)
    second = a.group(2)+a.group(3)
    print first
    print second

Output:

Speciality: "Aesthetic Medicine, Oncology" 
Profession: "Physician (MD, DO, Resident)"

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to split String before first comma?

From Dev

Split string at specific character with optional comma

From Dev

split by comma inside a string using javascript

From Dev

Split string by space and comma using regex

From Dev

Python - String.split() using delimiter ',', but there is price in string also using comma in thousand

From Dev

python split a string by comma not inside matrix expression

From Dev

Ruby - How to split a string before specific keywords

From Dev

Dataframe split before a specific string for all rows

From Dev

Dataframe split before a specific string for all rows

From Dev

regexp to split a string using comma(,) delimiter but ignore if the comma is in curly braces{,}

From Dev

Split String Using comma but ignore comma if it is brackets or quotes

From Java

String Split with comma and newline

From Dev

Split string on newline and comma

From Dev

Split a comma separated string but only split by a comma

From Dev

VBA How to keep a specific comma after string split

From Dev

How do I split or grab a string in python after a comma in python

From Dev

Split string on comma and ignore comma in double quotes

From Dev

Split string containing comma with comma delimiter

From Dev

Python string split using regex

From Dev

Split string using regex python

From Dev

Split unbalanced GEO string on comma

From Dev

Split string in with some comma separators

From Dev

string split on last comma in R

From Dev

How to split a String on the basis of comma

From Dev

Split string by comma, but not escaped in JavaScript

From Dev

split comma separated string in sql

From Dev

Comma is causing unwanted string split

From Dev

split comma separated string into columns

From Dev

How to split a comma seperated string and insert into html using javascript

Related Related

  1. 1

    How to split String before first comma?

  2. 2

    Split string at specific character with optional comma

  3. 3

    split by comma inside a string using javascript

  4. 4

    Split string by space and comma using regex

  5. 5

    Python - String.split() using delimiter ',', but there is price in string also using comma in thousand

  6. 6

    python split a string by comma not inside matrix expression

  7. 7

    Ruby - How to split a string before specific keywords

  8. 8

    Dataframe split before a specific string for all rows

  9. 9

    Dataframe split before a specific string for all rows

  10. 10

    regexp to split a string using comma(,) delimiter but ignore if the comma is in curly braces{,}

  11. 11

    Split String Using comma but ignore comma if it is brackets or quotes

  12. 12

    String Split with comma and newline

  13. 13

    Split string on newline and comma

  14. 14

    Split a comma separated string but only split by a comma

  15. 15

    VBA How to keep a specific comma after string split

  16. 16

    How do I split or grab a string in python after a comma in python

  17. 17

    Split string on comma and ignore comma in double quotes

  18. 18

    Split string containing comma with comma delimiter

  19. 19

    Python string split using regex

  20. 20

    Split string using regex python

  21. 21

    Split unbalanced GEO string on comma

  22. 22

    Split string in with some comma separators

  23. 23

    string split on last comma in R

  24. 24

    How to split a String on the basis of comma

  25. 25

    Split string by comma, but not escaped in JavaScript

  26. 26

    split comma separated string in sql

  27. 27

    Comma is causing unwanted string split

  28. 28

    split comma separated string into columns

  29. 29

    How to split a comma seperated string and insert into html using javascript

HotTag

Archive