c - 进行 URL 匹配和标签提取的有效方法是什么?

标签 c string algorithm pattern-matching go

给定两个字符串 a = "/some/{tag}/here"b = "/some/text/here" 我想要一个高效的算法验证 b 是否匹配 a 定义的模式,如果匹配则提取变量中 b 的相应部分(即:tag = "文本")。

也欢迎使用 C 或 Go 实现,但伪代码也可以。

最佳答案

了解 the Knuth–Morris–Pratt string searching algorithm .应该给你所有你需要的,包括伪代码。

关于c - 进行 URL 匹配和标签提取的有效方法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10163118/

相关文章:

c - C中的限定符和修饰符有什么区别?

c - 不使用 '.' 或 '->' 运算符访问结构体成员

c - 如何将 scanf 和 if 与字符串一起使用? (非常基础)

string - 将包含字符串的文件 move 到与原始文件同名的子文件夹 (PowerShell)

algorithm - 该算法的渐近时间复杂度

c++ - 将 Tcl 中命令的输出重定向到文件时,文件以 DOS 格式生成

python - 无法编译需要 C99 编译器 (AFAIU) 的 pyethash python 包。错误 - 无法打开包含文件 : 'alloca.h'

c# - 如何在不使用系统命名空间的情况下使用字符串

: All possible ways of splitting a set of elements into two sets? 的算法

python - 替换python列表中的特定字符