elexy 发表于 2015-1-6 07:57:39

[已解决]神奇的字符串,请教一个正则公式

本帖最后由 elexy 于 2015-1-7 07:26 编辑

[相关参数:p_admin_account = 123456789 p_fund_account = 38268877 p_branch_no = 0 p_exchange_type = 2 ]

account 里面的数字位数随机,有时候9位,有时候10位,有时候11位,有时候前面有个字母,即A44557780

求取第一个adminaccount的值,有可能是字母开头Local $Str = '[相关参数:p_admin_account = 123456789 p_fund_account = 38268877 p_branch_no = 0 p_exchange_type = 2 ]'
Local $Test = StringRegExpReplace($str, ???, '$1')
MsgBox(0, $Test, $Str)
无意中发现把代码粘到编辑器里,会出来个 FS 符号,不知道咋回事

afan 发表于 2015-1-6 12:47:34

Local $Str = '[相关参数:p_admin_account = 123456789 p_fund_account = 38268877 p_branch_no = 0 p_exchange_type = 2 ]'
Local $Test = StringRegExp($str, '\w?\d+', 1)
If Not @Error Then MsgBox(0, $Test, $Str)

dhlhmgc 发表于 2015-1-6 23:21:23


Local $Str = '[相关参数:p_admin_account = A123456789 p_fund_account = 38268877 p_branch_no = 0 p_exchange_type = 2 ]'
;Local $Test = StringRegExp($str, '\w?\d+', 3)                               
;Local $Test = StringRegExp($str, '\w? *\= *(\w+)', 3)
Local $Test = StringRegExp($str, '\w?\s*\=\s*(\w+)', 3)

if @error then
        msgbox(48,0,"Error!")
Else
        _ArrayDisplay($Test,"测试2 - test")
Endif
页: [1]
查看完整版本: [已解决]神奇的字符串,请教一个正则公式