Convert Hexadecimal Formatted Arduino String to Number

I have an Arduino string (not a char array), that is formatted like this: "0x????", where "?" could be any value from 0 to F. In other words, it is a 4 digit hexadecimal value, but in a string. How can I convert it from a string and into an unsigned integer? Thanks!

I have an Arduino string (not a char array)

A string IS a char array. A String is not. Which DO you have?

You can get the string from the String, if that is what you have, using toCharArray() on the String instance.

Then, strtol() can convert that to a long.

Well, I said not a char array, meaning that I would have a String. Will strtol() convert text formatted like "0x000" to a number too?

Well, I said not a char array, meaning that I would have a String.

But, you also said string, not String.

Will strtol() convert text formatted like "0x000" to a number too?

Yes. The 0x is correctly recognized as meaning that the characters are hexadecimal characters and that the base is 16.