Skip to main content
10 events
when toggle format what by license comment
Oct 11, 2019 at 5:30 vote accept alvas
Oct 11, 2019 at 5:30
Oct 4, 2019 at 19:19 comment added Ismael Miguel @AustinHastings I was asking because I didn't knew if it was required to capture the separator for it to be part of the result. But thinking about it, it would be pretty weird if the default behaviour was to include the separator, with no option to do not include it in the results. But thank you
Oct 4, 2019 at 18:13 comment added aghast @IsmaelMiguel: This is the OP's use case. He wants the punctuation as well as the non-punctuation. That's a documented behavior of re.split, that if you use capture groups the capture text is included in the result.
Oct 4, 2019 at 15:33 comment added BruceWayne Also, if you have Python 3, they already included regex as re, for free! What a deal!
Oct 4, 2019 at 13:44 comment added rolfl The capturing group is required, @IsmaelMiguel - otherwise the punctuation itself would be discarded in the split.
Oct 4, 2019 at 10:52 comment added Dai "I used to have a problem, so I used a regular-expression, now I have two problems."
Oct 4, 2019 at 10:25 comment added Ismael Miguel Is the capturing group required in (\p{Punctuation})? If it isn't required, isn't it better to just do \p{Punctuation} instead? (aka: no capturing group).
Oct 4, 2019 at 4:32 comment added aghast @alvas Yes, they both reflect the unicode-category of the underlying character.
Oct 4, 2019 at 3:47 comment added alvas Is unicodedata.category(char).startswith("P") the same as regex's \p{Punctuation}?
Oct 4, 2019 at 3:36 history answered aghast CC BY-SA 4.0