python - python中的正则表达式来管理 "-"

标签 python regex

我正在寻找适合ready-to-workready-to-work-todayready-to的正则表达式>。我一直这样放置多个选项:

text=''' ready-to-work ready-to ready-to-work-today'''

re.findall(r'\b[a-zA-Z0-9]+?-[a-zA-Z0-9]+?-[a-zA-Z0-9]+?\b', text)

我已成功找到最多三个术语的表达式,例如 ['ready-to-work'],但我无法捕获 ready-to今天准备工作。我希望['准备工作','准备','准备今天工作']

感谢您的帮助。

最佳答案

尝试这个正则表达式\b\w+(-\w+)+\b

关于python - python中的正则表达式来管理 "-",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57044076/

相关文章:

python - 如何提高图像质量?

C# Regex Split - 引号外的逗号

python - 如何在Python中进行时间序列分析时组合两个折线图进行数据验证

python - 为什么我在 pygame 中的玩家角色有时会消失在瓷砖后面,但仍然会移动?

regex - -匹配成功但不更新 $matches

regex - 检查字符串中是否有日期并提取字符串的一部分

regex - 在Delphi中使用Regex替换字符串

JavaScript 正则表达式 : Non-Digit Character

python - 如何在 Django 中链接到我的 GCS Bucket JSON 凭证文件?

python - Flask-Ask:如何修复 'flask.debughelpers.FormDataRoutingRedirect' 错误?