Regex test if valid asset name

The regular expression /[1][A-Z]{3,11}$/ tests whether a string is a valid asset name.

To allow for lowercase characters, use /[2][a-zA-Z]{3,11}$/

/\b[B-Z][A-Z]{3,11}\b/ finds the first valid uppercase asset name within the string.

Add g to find all asset names; /\b[B-Z][A-Z]{3,11}\b/g


You can test a regex on [regex101.com][1].


For example, to find all assets within a string with PHP, you may use this code:

$text = 'My favorite XCP assets are FLDC, BITCRYSTALS and YACHTMONEY!';
preg_match_all('/\b[B-Z][A-Z]{3,11}\b/', $text, $matches);
for ($i = 0; $i < count($matches[0]); ++$i) {
    print $matches[0][$i].' ';
}

Note: A valid asset name needs to meet four conditons

  • Only characters A-Z
  • First character not A
  • Minimum length is 4
  • Maximum length is 12

Earlier it was possible to register longer names. There are a few 13 and 14 character names, but none of these are in active use.
[1]: https://regex101.com/


  1. B-Z ↩︎

  2. b-zB-Z ↩︎

Another PHP example.

To test if a string is a valid asset name, use this code:

$asset = 'MYASSET';
if (preg_match('/^[B-Z][A-Z]{3,11}$/', $asset)) {
	echo "$asset is a valid asset name"; 
} else {
	echo "$asset is NOT a valid asset name"; 
}

Javascript tests for both alphabetic and numeric asset names: