📌  相关文章
📜  从字符串中删除第一个和最后一个字符 - R 编程语言代码示例

📅  最后修改于: 2022-03-11 14:51:58.714000             🧑  作者: Mango

代码示例1
# Two Methods to remove the first and last characters from a string variable in R:
# Example string
string = "%_adcknqwe4adflewgfgfrgaqe23_%"

# Using gsub
string_gsub <- gsub(pattern = '^.|.$', replacement = '', x = string)

# Using substr + counting characters w/ nchar():
string_substr <- substr(string, start=2, stop=nchar(string)-1)