[已解决]求一个正则表达式
本帖最后由 elexy 于 2010-6-30 08:28 编辑文本文件的格式大概是这样的
1423457DR0751123874167462010-01-01 15:30
1426557DR0751123874167462010-01-01 14:30
1424557DR0751123874167462010-01-01 12:30
1423457DR0751123874167462010-01-01 11:30
...............
我现在是想取每行前七个数字,我用的是 \d\d\d\d\d\d\d ,确实可以取到数,但是这样的正则表达式会连第三列的数12387416746也取了7个数字,请问怎么改表达式可以避免这种情况? #include <Array.au3>
$Str = _
'1423457DR0751123874167462010-01-01 15:30' & @CRLF & _
'1426557DR0751123874167462010-01-01 14:30' & @CRLF & _
'1424557DR0751123874167462010-01-01 12:30' & @CRLF & _
'1423457DR0751123874167462010-01-01 11:30'
$sR = StringRegExp($str, '(?m)^(\d{7})\h', 3)
_ArrayDisplay($sR, '') 新手!!学习了!!谢谢!! 谢谢AFAN超版!!!!!!学习了!
#include <Array.au3>
$Str = _
'1423457DR0751123874167462010-01-01 15:30' & @CRLF & _
'1426557DR0751123874167462010-01-01 14:30' & @CRLF & _
'1424557DR0751123874167462010-01-01 12:30' & @CRLF & _
'1423457DR0751123874167462010-01-01 11:30'
$sR = StringRegExp($str, "\b\d{7}\b", 3)
_ArrayDisplay($sR, '')
正則表達式,學習了。^_^
页:
[1]