问题是针对perl的。
例如,如果我有 "hello.world"
并且指定的字符是 '.'
那么我想要的结果是 "hello"
.
最佳答案
见 perldoc -f index
:
$x = "hello.world";
$y = substr($x, 0, index($x, '.'));
关于string - 如何获取给定字符串的子字符串,直到第一次出现指定字符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8256382/