是否有正则表达式、python 或 javascript 方法来搜索句点、单词和定义,然后将其附加到字典或其他对象?
例如:
. Reversion: A reversion is turning back again to a previous state or condition. Rhetoric: Rhetoric is the skill or art of using language to persuade or influence people, especially language that sounds impressive but may not be sincere or honest.
这将变成 {"Reversion": "A reversion is going again back to a previous state or condition", "Rhetoric": "Rhetoric is the skill or art of using language to persuase or influence people, especially听起来令人印象深刻但可能不真诚或诚实的语言”
最佳答案
过滤掉单词和定义的正则表达式是:
\.\s*([^:]*)\s*:\s*([^.]*)
演示:https://regex101.com/r/utgrCb/1/
\.\s*
起始点和可选空格([^:]*)
“单词”是冒号前的所有内容\s*:\s*
冒号用可选空格包围([^.]*)
“定义”是最后一个点之前的所有内容https://stackoverflow.com/questions/66022702/
相关文章:
reactjs - 有没有 Ionicons : Icon props?
vuejs3 - vue3 中 shallowReactive 和 shallowRef 的区别?
python - 如何连接来自 3 个小整数的字节以生成由 Python 中的这些字节表示的更大数字
react-native - react native : Refresh Controll not
flutter - 如何根据 flutter 中的文本高度调整容器高度?
haskell - 为什么 map 使用的这个函数需要返回一个(单例)列表而不是一个元素?