0

In general I have a string say

temp = "ProgramFields"

Now I want to split strings like these into two terms(I can identify tow strings based on uppercase character)

term1  = "Program"
term2  = "Field"

How to achieve this in python? I tried regular expression and splitting terms but nothing gave me the result that I expected Python code -

re.split("[A-Z][a-z]*","ProgramField")

Any suggestions?

user3059993
  • 324
  • 1
  • 4
  • 9

1 Answers1

1

You have to include groups:

re.split('([A-Z][a-z]*)', 'ProgramField)
Justin Niessner
  • 242,243
  • 40
  • 408
  • 536