首页 > 编程语言 > AAuto > AAuto string.replace格式化字符串
2013
02-25

AAuto string.replace格式化字符串

如“0201512b”,需要格式化成“02 00 51 2B”,可以用string.replace函数分组捕获,然后追加个空格。

import console

str = /*
0201512b233f00002710024e0044004500530043003d624b673a817e8baf7f51003a0025003000617b2c003800355c4a596565af536191d150cf5956843d4e0b5e375e55ff0c672c00250032003600230038003200320036003b963f5f1783b1514b62675bfc7684300a900379bb5fb79ed15170300b83b767004f735f7172475956ff0c674e5b89300a5c115e746d3e300b83b7530562ec67004f735bfc6f1457285185768456db59275956ff0c621059278d625bb63002002600520045005300500043004f004e0044004900540049004f004e003d004d0041004e00550041004c002600520045005300500043004f004e00540045004e00540053003d002600520045005300500043004f004e00540045004e005400540059005000450053003d0054004d00540057004100500049002600520045005300500044004500530043003d8be660c5002600520045005300500044004500530054003d0068007400740070003a002f002f0069006e0066006f002e00330067002e00710071002e0063006f006d002f0067002f0073003f00610069006400250033006400740065006d0070006c0061007400650025003200360074006900640025003300640065006e0074005f006f007300630061007200380035002500320036007400690064002500330064003100320039003400330025003200360067005f0066002500330064003500320034002500320036006900630066006100250033006400730075006200630072005f006d007100710026005300550042004a004500430054003d300a900379bb5fb79ed15170300b83b7596565af536167004f73
*/

str = string.replace(str,".{2}","\1 ")
str = string.upper(str)
console.log(str)
最后编辑:
作者:NINE
这个作者貌似有点懒,什么都没有留下。

留下一个回复

你的email不会被公开。