L
LaundroMat
Hi,
I'm quite new to regular expressions, and I wonder if anyone here
could help me out.
I'm looking to split strings that ideally look like this: "Update: New
item (Household)" into a group.
This expression works ok: '^(Update?(.*)(\(.*\))$' - it returns
("Update", "New item", "(Household)")
Some strings will look like this however: "Update: New item (item)
(Household)". The expression above still does its job, as it returns
("Update", "New item (item)", "(Household)").
It does not work however when there is no text in parentheses (eg
"Update: new item"). How can I get the expression to return a tuple
such as ("Update:", "new item", None)?
Thanks in advance,
Mathieu
I'm quite new to regular expressions, and I wonder if anyone here
could help me out.
I'm looking to split strings that ideally look like this: "Update: New
item (Household)" into a group.
This expression works ok: '^(Update?(.*)(\(.*\))$' - it returns
("Update", "New item", "(Household)")
Some strings will look like this however: "Update: New item (item)
(Household)". The expression above still does its job, as it returns
("Update", "New item (item)", "(Household)").
It does not work however when there is no text in parentheses (eg
"Update: new item"). How can I get the expression to return a tuple
such as ("Update:", "new item", None)?
Thanks in advance,
Mathieu