Pull int from string if within square brackets

Hello. Having a hard time with this. I have a bunch of strings that look like this:

[0]This is some text.

[12]This is some more text.

[3]This is even more text.

I need to pull the number from the square brackets at the start of each line and convert to int during a for loop. How can I do this?

Thanks for any help.

PS I Forgot to mention but I’m trying to do this in Javascript, not C#

Use Regex, then parse the string into an int.