首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Flash >

字符串检测功能的AS

2012-02-20 
求一个字符串检测功能的AS假如有一段字符串,要检测并取出以某些字符开始的某段指定的字符串,例如在下面这

求一个字符串检测功能的AS
假如有一段字符串,要检测并取出以某些字符开始的某段指定的字符串,例如在下面这段文字中,要取出以“If you”开始的那句话“If you are not making progress”,这个功能的AS怎么写?

Be yourself. Work toward a goal that you can achieve with your body. Don't try to change your basic shape or to go against your own unique physical capabilities. Take an objective look at yourself, then work toward enhancing what you've got rather than trying to attain someone else's body.

Do your research. If you are not making progress, ask a qualified personal trainer to analyze your routine and your goals. Read health and fitness magazines. There's tons of great fitness information out there tailor it to fit you.



[解决办法]
正则表达式

JScript code
var st:String = 你的文本var reg:RegExp = /If you .*,/trace(reg.exec(st))
[解决办法]
楼上回答正确,用正则表达式。AS3可以直接使用正则表达式,AS2需要自己去下载一个正则的包。
AS3的正则支持并不是那么强大,全局搜索时如果有多个匹配,要循环匹配才可以。
[解决办法]
JScript code
var xx:XML=<test>Be yourself. Work toward a goal that you can achieve with your body. Don't try to change your basic shape or to go against your own unique physical capabilities. Take an objective look at yourself, then work toward enhancing what you've got rather than trying to attain someone else's body.Do your research. If you are not making progress 1, ask a qualified personal trainer to analyze your routine and your goals. Read health and fitness magazines. There's tons of great fitness information out there tailor it to fit you.Be yourself. Work toward a goal that you can achieve with your body. Don't try to change your basic shape or to go against your own unique physical capabilities. Take an objective look at yourself, then work toward enhancing what you've got rather than trying to attain someone else's body.Do your research. If you are not making progress 2, ask a qualified personal trainer to analyze your routine and your goals. Read health and fitness magazines. There's tons of great fitness information out there tailor it to fit you.Be yourself. Work toward a goal that you can achieve with your body. Don't try to change your basic shape or to go against your own unique physical capabilities. Take an objective look at yourself, then work toward enhancing what you've got rather than trying to attain someone else's body.Do your research. If you are not making progress 3, ask a qualified personal trainer to analyze your routine and your goals. Read health and fitness magazines. There's tons of great fitness information out there tailor it to fit you.Be yourself. Work toward a goal that you can achieve with your body. Don't try to change your basic shape or to go against your own unique physical capabilities. Take an objective look at yourself, then work toward enhancing what you've got rather than trying to attain someone else's body.Do your research. If you are not making progress 4, ask a qualified personal trainer to analyze your routine and your goals. Read health and fitness magazines. There's tons of great fitness information out there tailor it to fit you.</test>;var str:String=xx.toString();var re:RegExp=/If you [\w\s]*/gi;var o:Object;while((o=re.exec(str))!=null){    trace(o);} 

热点排行