日期:2014-05-17  浏览次数:20766 次

判断字符出现的位置,然后截取字符串!
有下列这些字符串,我想判断‘*’和‘-’出现的为止,然后截取‘*’之前的字符串,‘*’到‘-’之间的字符串,‘-’之后的字符串。

例:
aaa*2121-9988
bbfdke*2353-235322
哈哈*98739-29938

处理后的结果:
a =aaa b=2121 c=9988
a=bbfdk b=2353 c=235322
a=哈哈 b=98739 c=29938

------解决方案--------------------
SQL code
substr('xxxxx',1,instr('xxxxx','*')-1)
substr('xxxxx',instr('xxxxx','*')+1,instr('xxxxx','-')-instr('xxxxx','*')-1)
substr('xxxxx',instr('xxxxx','-')+1)