Liam0205 / liam0205.github.io

Deployment of my weblog.
https://liam0205.github.io
35 stars 5 forks source link

在 C++ 中读取字符串中成对定界符中的子串 | 始终 #166

Open Liam0205 opened 5 years ago

Liam0205 commented 5 years ago

https://liam.page/2017/03/13/read-substrings-from-paired-delimiters-in-Cpp/

这篇文章是一个简单的记录,解决类似这样的问题。 假设有一个字符串 1std::string = "<foo:bar> <baz:qux>"; 要怎样才能读出其中的 foo:bar 以及 baz:qux 呢?使用 regex 正则库当然是一个办法,不过在规整的情况下,我们还有更优雅的选择。