Trying to regex in ruby using this:
/UTC\s.\d{4}/
This picks up both
UTC +0000 UTC -0800
The codebase I'm working with uses:
/UTC\s\-?\d{4}/
Which picks up
UTC +0000 UTC -0800
The period isn't the best alternative, because it's going to pick up anything besides the acceptable +/-. Thoughts?
If you want to validate potentially incorrect strings, you might want to force the leading 0:
If you want to accept non-standard strings, you might make the 0 optional, too: