我有一个字符串<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js">
</script>
<form action="#" method="post" id="new_tide">
Title: <input id="titlenewtide" type="text" name="title" required> <br>
Description: <textarea name="description" id="description" required></textarea> <br>
Tag: <input id="newtag" type="text" name="newtag" required> <br>
Category: <input type="radio" name="category" value="19" required> Animation
<button type="submit" value="Submit" name="subnewtide" id="subnewtide" disabled="disabled">Submit</button>
</form>
。我希望在"00_123.txt"
之前获取字符串的第一部分,即"."
我发现"00_123"
可以做到。但问题是我不知道substring("00_123.txt", 0, stop)
的位置,因为&#34; 00_123&#34;可以改变。
我该怎么做?
答案 0 :(得分:1)
x <- "00_123.txt"
gsub("\\..*$", "", x)
[1] "00_123"