Bloomberg Ticker Regex for Go
/^[A-Z0-9]{1,12}(?:[:/]\s?[A-Z0-9]{1,2}|(?:\s[A-Z]{2}))(?:\s(?:Equity|Corp|Index|Curncy|Comdty))?$/What this pattern does
This page provides a comprehensive, battle-tested regular expression for matching bloomberg ticker, ported and verified for Go. Financial data validation has zero tolerance for false negatives — a missed invalid entry can corrupt downstream calculations. The snippet below is ready to drop into your Go project — whether you're validating in a Gin handler, a gRPC service, or a command-line tool.
Go Implementation
// Bloomberg Ticker
// ReDoS-safe | RegexVault — Finance > Securities & Trading
package validation
import "regexp"
var bloombergTickerRe = regexp.MustCompile(`^[A-Z0-9]{1,12}(?:[:/]\s?[A-Z0-9]{1,2}|(?:\s[A-Z]{2}))(?:\s(?:Equity|Corp|Index|Curncy|Comdty))?$`)
func ValidateBloombergTicker(s string) bool {
return bloombergTickerRe.MatchString(s)
}
// Example
// fmt.Println(ValidateBloombergTicker("AAPL US")) // trueTest Cases
Matches (Valid) | Rejects (Invalid) |
|---|---|
AAPL US | AAPL |
AAPL:US | aapl US |
TSLA US Equity | AAPL:USA |
BP/ LN | AAPL US EQUITY lowercase |
7203 JP | — |
When to use this pattern
This pattern is drawn from the Finance > Securities & Trading category and carries a ReDoS-safe certification. That matters for Go developers because Go's RE2 engine is inherently safe from catastrophic backtracking, but this pattern has been additionally verified for correctness. RegexVault audits patterns against known backtracking attack vectors, ensuring you have the necessary context before using this regex in a high-stakes production environment.
Common Pitfalls
Bloomberg tickers are proprietary. Different terminals may display the same security with slightly different ticker formatting. Do not use Bloomberg tickers as primary identifiers — use ISIN or FIGI.
Technical Notes
Bloomberg format: security identifier + exchange/country code + optional asset class (Equity, Comdty, Corp, Govt, Curncy). This pattern matches the ticker+exchange portion. Full Bloomberg parsing requires the asset class suffix.
Have a pattern that belongs in the vault?
Submit it for review — community-verified patterns get credited to your GitHub handle. Free submissions join the queue. Priority review available for $15.
Submit a Pattern