尝试匹配字符串,其中一个与
匹配有人可以为我解释这种行为吗?使用stringr
函数时,未检测到匹配,但在使用==
进行检查时,它是?
str_detect(str_sub(bit1, 1485, 1739), snips[10])
# [1] FALSE
str_sub(bit1, 1485, 1739) == snips[10]
# [1] TRUE
当我查看str_sub(bit1, 1485, 1739)
和snips[10]
时,它们看起来完全相同,实际上来自相同的原始素材。
以下是实际的文本块:
str_detect("HANOI - China has shut trade ports to Vietnamese vessels as the bird flu crisis deepens, the Xinhua News Agency reported. Some 40 ports along a 740-mile (791 kilometers) border with Vietnam have been closed in the southern Chinese province of Yunnan, stat", "HANOI - China has shut trade ports to Vietnamese vessels as the bird flu crisis deepens, the Xinhua News Agency reported. Some 40 ports along a 740-mile (791 kilometers) border with Vietnam have been closed in the southern Chinese province of Yunnan, stat")
[1] FALSE
甚至是这个结果?
str_detect(str1, str1)
[1] FALSE