I want to extract an ID from a string which has the form “somethinguseless_XXXXX “.
XXXXX is the ID I need. The string always has the same length and the format won’t change over time.
I found 2 solutions to extract the ID => oldAttribute.substring(17,22) or Regex.Match(oldAttribute,@"_([0-9]{5})").Groups[1].value.
Which one do you think is better than the other?
If the length is consistent,
Substring()will work just as well and likely perform better. A quick test over a few million iterations would probably verify that assumption.