Just use the split
function. It returns a list, so you can keep the first element:
>>> s1.split(':')
['Username', ' How are you today?']
>>> s1.split(':')[0]
'Username'
More Related Contents:
- Split string on whitespace in Python [duplicate]
- Python regex: splitting on pattern match that is an empty string
- Splitting a math expression string into tokens in Python
- How to understand regular expression with python?
- Split a string by a delimiter in python
- Is there a simple way to remove multiple spaces in a string?
- How to correctly sort a string with a number inside? [duplicate]
- Fast punctuation removal with pandas
- Split a string at uppercase letters
- Why are empty strings returned in split() results?
- Splitting a string into words and punctuation
- Python regex match OR operator
- Find longest repetitive sequence in a string
- Product code looks like abcd2343, how to split by letters and numbers?
- Get last “column” after .str.split() operation on column in pandas DataFrame
- Splitting a semicolon-separated string to a dictionary, in Python
- How to extract an IP address from an HTML string?
- Regex for existence of some words whose order doesn’t matter
- Split a string only by first space in python
- Split string on commas but ignore commas within double-quotes?
- How to split strings inside a list by whitespace characters
- Remove duplicate chars using regex?
- How to remove symbols from a string with Python? [duplicate]
- How to split a string by commas positioned outside of parenthesis?
- Remove Sub String by using Python
- How to split a Python string on new line characters [duplicate]
- Split text after the second occurrence of character
- Split a string into 2 in Python
- How can I split by 1 or more occurrences of a delimiter in Python?
- Adding characters after a certain word in Python using regex