可能的重复:
从 C# 中的路径字符串获取文件名
使用:c# asp.net vs10
假设, filepath = "C:\Sys\Axa_Excel\Axa123.xlsx"。文件路径是一个字符串变量。文件可以来自任何位置。但文件将始终为 xls/xlsx/csv。我如何只从只是一个字符串的文件路径中获取文件名?
我想知道excel VBA中是否有子串函数允许我根据开始和结束位置提取字符串?我知道有左右,但它们只允许一个长度,我的子串可以是可变长度.任何帮助将不胜感激!
如何在最后'/'后得到字符串的值
string path=http://localhost:26952/Images/Users/John.jpg
Run Code Online (Sandbox Code Playgroud)
我希望得到类似的结果: John.jpg
例如:有一个字符串:
'Trump is great#Trump is great#'
Run Code Online (Sandbox Code Playgroud)
如果我做:
'Trump is great#Trump is great#'.delete! 'Trump is great#'
Run Code Online (Sandbox Code Playgroud)
我会得到:
''
Run Code Online (Sandbox Code Playgroud)
但我想得到:
'Trump is great#'
Run Code Online (Sandbox Code Playgroud)
所以我想要一个范围'Trump is great#',并按此范围删除此子字符串。
怎么做?
还是其他删除子字符串的方法?
我是C#的新手,不知道如何在电子邮件地址中获取子字符串.
例如,如果电子邮件地址是:name.surname@company.com或support@company.com我想知道如何从这个电子邮件地址中分离信息?
比如name.surname@company.com
string _name = name;
string _surname = surname;
string _company = company;
string domaine = company.com;
Run Code Online (Sandbox Code Playgroud)
或者如果它只是support@company.com那么
string _name = support;
string _company = company;
string domaine = company.com
Run Code Online (Sandbox Code Playgroud)
谢谢您的帮助
在这里我不明白"al"的索引如何获得4的输出,因为a和l不在一起,对于所有其他组合,它给出-1.
package javaBasics1;
public class MainMethod {
public static void main(String name[]){
int x = 1,y = 5;
String a = "animals";
System.out.println(a.indexOf("al"));
}
}
Run Code Online (Sandbox Code Playgroud) 如果我有“var”,我怎样才能从中得到“e,o,o”?使用子字符串只能获取位置
var str = "Hello world!";
var res = str.substring(1, 4);
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Substring以下分割线
MARAMBIO MBI VORD-64.235000 -56.620278117.00H
Run Code Online (Sandbox Code Playgroud)
如
对于前两个单词,我的代码是:
string firstPart = lines[17].Substring(0, 23);
string secondPart = lines[17].Substring(24, 27);
Run Code Online (Sandbox Code Playgroud)
但是,字符串firsPart的输出是正确的
secondPart给了我MBI VORD-64.235000 -56.6202正如我所期待的MBI那样,他们只有24,25,26和27.
我究竟做错了什么?
我有字符串:
我必须提取"湿度:"之后的所有数字,...我正在考虑使用Regex类,但我不确切知道如何做到这一点
我获取串行数据的代码:
namespace Demo1Arduino
Run Code Online (Sandbox Code Playgroud)
{
public partial class MainWindow : Window
{
private SerialPort port;
DispatcherTimer timer = new DispatcherTimer();
private string buff;
public MainWindow()
{
InitializeComponent();
}
private void btnOpenPort_Click(object sender, RoutedEventArgs e)
{
timer.Tick += timer_Tick;
timer.Interval = new TimeSpan(0, 0, 0, 0, 500);
timer.Start();
try
{
port = new SerialPort(); // Create a new SerialPort object with default settings.
port.PortName="COM4";
port.BaudRate = 115200; // …Run Code Online (Sandbox Code Playgroud) 我有一个代码,应该从字符串中取出2个元素.使用字母数字可以正常工作,但是当我输入一个相同数字的字符串,即只是"1":( 111111111)时,不返回任何东西,或只返回"1"或与我的预期非常不同的东西.
这是我的代码:
String str= "222222222";
System.out.println(str.replace(str.substring(3, 5), "")); }
Run Code Online (Sandbox Code Playgroud)
在这种情况下,返回"2",但如果字符串少了一个"2",则不返回任何内容
我赞成你的帮助:)