python - re.findall 的结果顺序有保证吗?

标签 python regex python-3.x

re.findall 返回的匹配列表是否始终与它们在源文本中的顺序相同?

最佳答案

是的,如 re 模块中所述 docs :

Return all non-overlapping matches of pattern in string, as a list of strings. The string is scanned left-to-right, and matches are returned in the order found.

关于python - re.findall 的结果顺序有保证吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35133386/

相关文章:

python - 如何将 for 循环推进 2 次迭代?

dictionary - 在 python 中,map(func,list) 和 [func(x) for x in list] 有什么区别

java - 远程系统事件通知库

python - "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' ' at line 1"

javascript - 设置值后 PHP 变量似乎为空

c# - 尝试替换空字符串时无法识别的转义序列

python - 将枕头 Gif 复制到 Windows 剪贴板

python - 如果使用 getattr,如何从同一个文件调用函数?

javascript - 如何创建包含 <td> 元素值的数组?

python - 在 Linux 上使用 Python 即时将 .doc/.docx 从 URL 转换为 .pdf