| |

VerySource

 Forgot password?
 Register
Search
View: 910|Reply: 5

How to get the contents of x and y in the city of x and y? X and Y are variables! Regular

[Copy link]

2

Threads

4

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-1-20 22:40:01
| Show all posts |Read mode
How to get the contents of x and y in the city of x and y? X and Y are variables! Regular
Expert advice
Use regular or other methods!
Reply

Use magic Report

0

Threads

15

Posts

10.00

Credits

Newbie

Rank: 1

Credits
10.00

 China

Post time: 2020-2-1 13:54:01
| Show all posts
You use a drop-down list, after selecting the value, you can directly read the selected value?
Reply

Use magic Report

0

Threads

11

Posts

11.00

Credits

Newbie

Rank: 1

Credits
11.00

 China

Post time: 2020-2-5 14:00:01
| Show all posts
string yourStr = ......;

MatchCollection mc = Regex.Matches (yourStr, "(. *?) Province (. *?) City", RegexOptions.IgnoreCase);

foreach (Match m in mc)
{
    m.Groups [1] .Value; // Province name, such as Shandong
    m.Groups [2] .Value; // city name, such as Qingdao
}
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-9-2 17:30:01
| Show all posts
[code=C#] string str = "X Province, Y City"; //Define or accept your string containing the province and city
        string[] shengs = str.Split('province').ToString(); // Define an array to store the strings before and after the province.
        string sheng = shengs[0].ToString();// The first string in the shengs array is X
        string []shis = shengs[1].Split('市').ToString(); //..
        string shi = shi[1].ToString();[/code]
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-9-2 17:45:01
| Show all posts
If it is: Jinan City, Shandong Province

string str1 = "Jinan City, Shandong Province";
string[] str2 = str1.Split("province");
string[] str3 = str2[1].Split("市");

str2[0] is "Shandong"
str3[0] is "Jinan"
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-9-2 18:00:02
| Show all posts
Positive answer upstairs! ! !
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