Home > Net >  How to access the contents of the string the same symbol in the third symbol behind
How to access the contents of the string the same symbol in the third symbol behind

Time:09-16

String: a string triple="http://127.0.0.1:1111/Upload/20200417/aaa9754-4865-808e-94738f636b6c.png"
How to get the result: the Upload/20200417/aaa9754-4865-808 - e - 94738 f636b6c. PNG

CodePudding user response:

To learn how to use resource ~, this function should have a lot of information can be found, you will have to demand is emerged from the first N same characters began to intercept to the end of the string, need to have is this character when the NTH appear in the string to be digits, and then use the substring interception, below is for digits have a method, the incoming string is needed, special characters, how many times a
Public int findNumber (String STR, String letter, int num) {
Int I=0;
Int m=0;
Char c=new String (letter). CharAt (0);
Char [] ch=STR. ToCharArray ();
for(int j=0; jIf (ch [j]==c) {
I++;
If (I==num) {
M=j;
break;
}
}
}
Return m;
https://blog.csdn.net/arui_email/article/details/8800553

CodePudding user response:

If you include slashes like escape character, remember to escape

CodePudding user response:

String [] aaList=aaa. The Split ('/');
The string filename="";
For (int I=3; IFilename +=aaList [I] + "/";
Filename=filename. The substring (0, filename. The Length - 1);

CodePudding user response:


 
String triple=@ "http://127.0.0.1:1111/Upload/20200417/aaa9754-4865-808e-94738f636b6c.png";
//regular
Var res=Regex. Match (aaa, "Upload" (. +));
//the split way
Var res1="Upload" + aaa. The Split (new string [] {} "Upload", StringSplitOptions. RemoveEmptyEntries) [1].
//the substring way
Var res2=aaa. The Substring (aaa) IndexOf (" Upload "));

CodePudding user response:

 
String triple=@ "http://127.0.0.1:1111/Upload/20200417/aaa9754-4865-808e-94738f636b6c.png";
List SplitA=aaa. The Split ('/'). ToList ();
The string result=string. Join ("/", splitA GetRange (3, splitA. Count - 3));

CodePudding user response:

According to the big though moral emperor supreme instructions, I won't tell you the following code (because according to the moral standard of big however, make a mockery of what you don't know the uri is the following code)

 Uri Uri=new Uri (" http://127.0.0.1:1111/Upload/20200417/aaa9754-4865-808e-94738f636b6c.png "); 
String path=uri. LocalPath;
  •  Tags:  
  • C#
  • Related