找回密码
 加入
搜索
查看: 2673|回复: 4

[AU3基础] 请问几个正则表达式的写法[已解决]

[复制链接]
发表于 2011-3-15 20:17:40 | 显示全部楼层 |阅读模式
本帖最后由 chenlu_ling 于 2011-3-16 19:51 编辑
Local $theArray[10] = ["0","1","10","01","000","001","010","011","110","111"]
Local $a = "0"
Local $b = "1"
;请问以下三个问题如何实现,正则表达式怎么写?
;问题一:找出$theArray中首字符为$a的所有值
;问题二:找出$theArray中最后一个字符为$b的所有值
;问题三:找出$theArray中首字符为$a并且最后一个字符为$b的所有值

;当然循环去取值进行比较可以实现,不过我想用正则表达式直接比较出来。。。不知道能不能实现
多谢  三楼 3mile  代码很简洁
也谢谢二楼的 easied   你写的正则表达式也达到了预期效果
发表于 2011-3-15 20:51:29 | 显示全部楼层
学习正则,你这问题的核心我就当习题做了.你就帮我批改一下吧
Local $theArray[10] = ["0","1","10","01","000","001","010","011","110","111"]
Local $a = "0"
Local $b = "1"

For $i = 0 To UBound($theArray) - 1 Step 1
        If StringRegExp($theArray[$i], '^' & $a & '.*' & $b & '$', 0) Then
                MsgBox(4096, $i, $theArray[$i] & " 是字母是$a尾字母是$b的值")
        Else
                If StringRegExp($theArray[$i], '^' & $a, 0) Then MsgBox(4096, $i, $theArray[$i] & " 是首字母是$a的值")
                If StringRegExp($theArray[$i], $b & '$', 0) Then MsgBox(4096, $i, $theArray[$i] & " 是尾字母是$b的值")
        EndIf
Next
发表于 2011-3-16 11:45:20 | 显示全部楼层
#include <array.au3>
Local $theArray[11] = ["0","1","10","01","000","001","010","011","110","111",'01101']
local $a='0'
local $b='1'
$str=_ArrayToString($theArray)

$first=StringRegExp($str,"\b"&$a&"\d*",3)
_arraydisplay($first)

$end=StringRegExp($str,"\d*"&$b&"\b",3)
_ArrayDisplay($end)

$first_end=StringRegExp($str,"\b"&$a&"\d*"&$b&"\b",3)
_arraydisplay($first_end)
发表于 2011-3-16 13:40:58 | 显示全部楼层
回复 3# 3mile
 
WinActivate("http://10.60.65.99/sm/gaia.main.d - Windows Internet Explorer","")
WinActive("http://10.60.65.99/sm/gaia.main.d - Windows Internet Explorer","")
sleep(1000)
MouseClick("left", 1018,265,1,10)
sleep(1000)
MouseClick("left", 1036,351,1,10)
sleep(1000)
MouseClick("left", 291,186,1,10)
sleep(6000)
MouseClick("left", 218,157,1,10)
sleep(1000)
send("{ENTER}")
sleep(2000)
send("{TAB}")
sleep(2000)
send("{TAB}")
sleep(2000)
send("{ENTER}")
sleep(1000)
 
 楼主| 发表于 2011-3-16 19:48:10 | 显示全部楼层
回复 2# easied

谢了,正则表达式达到了效果
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-10-2 12:36 , Processed in 0.075152 second(s), 21 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表