| |

VerySource

 Forgot password?
 Register
Search
View: 729|Reply: 6

Ask a string interception problem

[Copy link]

2

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-2-21 20:00:01
| Show all posts |Read mode
There is a string "aaaaaaa_bbbbbbb". I want to intercept the character "bbbbbbb" after _. Which method should I use ???????
Reply

Use magic Report

0

Threads

6

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-5-2 12:15:01
| Show all posts
SubString ()
Reply

Use magic Report

1

Threads

11

Posts

11.00

Credits

Newbie

Rank: 1

Credits
11.00

 China

Post time: 2020-5-2 20:15:01
| Show all posts
int i = string.index ('-');
string = string.substring (i);
Reply

Use magic Report

0

Threads

17

Posts

14.00

Credits

Newbie

Rank: 1

Credits
14.00

 Invalid IP Address

Post time: 2020-5-3 17:45:01
| Show all posts
string str = "aaaaaaa_bbbbbbb";
int index = str.IndexOf ("_");
int length = str.Length;
if (index + 1> = length)
{
    // The last character is "_" and cannot be intercepted
    return;
}
string resultStr = str.SubString (index + 1, length-index-1);
Reply

Use magic Report

0

Threads

9

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

Post time: 2020-5-5 22:30:01
| Show all posts
string str = "aaaaa_bbbbb";
string [] strs = str.split ('_');
if (strs.length> 1)
messagebox.show (strs [1]);
Reply

Use magic Report

0

Threads

9

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

Post time: 2020-5-9 12:30:01
| Show all posts
targetkingis good
Reply

Use magic Report

0

Threads

4

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-5-12 15:45:01
| Show all posts
str = "aaaaaaa_bbbbbbb"
str2 = str.Split ('_') [1];
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list