Home>
let str: String = ["Tokyo (10)", "Osaka (20)", "Hokkaido (30)"]
If there is an array with the string

, I want to extract only the parts "10", "20", and "30".

Because the number of characters is not constant as shown above in the example,
The method of ◯ letter from the beginning cannot be used.

In my opinion,
The third character from the end, and the range of two characters from that point
I was wondering if it would be like that, but
I can't find anything good ...

I wonder if it is easy.

Thank you.

ー ー ー ー ー ー ー ー ー

This is a postscript.

I want to use this string (10 or 20) for sorting.
I want to use the extracted string as it is, so I want to embed it in one sentence without putting it in a variable.

  • Answer # 1

    I thought it was dejavu ^^;

    The answer code below
    https://StackOverflow.com/questions/225546

    [(. *?)]should be\ ((. *?) \).