如何从字符串中提取第一个数字

时间:2014-11-11 20:45:04

标签: regex powershell

我正在尝试使用powershell从长字符串中提取第一个数字。如何使用正则表达式仅从字符串中获取第一个数字?

字符串1:

000660007501S W RUSSELL DLC NO 41 SLY 2.5 FT OF ELY 313.82 FT OF FOLLOWING DESCRIBED PORTION OF SAMUEL W RUSSELL DONATION CLAIM`                     1000

字符串2:

010454040006ALDERBROOK DIV NO 05                                                                                                                    62000   14000040

字符串3:

012000012000ALEXANDER ACRE TRS S 1/2 OF LOT 38 TGW LOT 39 TGW N 45.96 FT OF E 109.23 FT LOT 40 LESS ANY POR PLTD DEVON LANE                         13000         38-39-40

1 个答案:

答案 0 :(得分:0)

我能够这样做:

$accountnumber = $p.Substring(0,16) -replace '\D+',''
$Parcelnumber = $accountnumber.Substring(0,10)