Regex 在Vb中如何在正则表达式中添加lookbehind

Regex 在Vb中如何在正则表达式中添加lookbehind,regex,vb.net,vb6,lookbehind,Regex,Vb.net,Vb6,Lookbehind,根据我的要求,我需要使用正则表达式检查三个条件 '找到点的位置 dotPos = InStr(editFormat, ".") '查找整数位数 wholeNum = Left$(editFormat, dotPos - 1) decNum = Mid(editFormat, dotPos + 1, strLen - dotPos - 1) regularExp = "^[-]{0,1}[0-9]{0," & wholeNum & "}\" & DecSep &a

根据我的要求,我需要使用正则表达式检查三个条件

'找到点的位置

 dotPos = InStr(editFormat, ".")
'查找整数位数

 wholeNum = Left$(editFormat, dotPos - 1)
decNum = Mid(editFormat, dotPos + 1, strLen - dotPos - 1)

regularExp = "^[-]{0,1}[0-9]{0," & wholeNum & "}\" & DecSep & "[0-9]{0," & decNum & "}$"
'查找小数位数

 wholeNum = Left$(editFormat, dotPos - 1)
decNum = Mid(editFormat, dotPos + 1, strLen - dotPos - 1)

regularExp = "^[-]{0,1}[0-9]{0," & wholeNum & "}\" & DecSep & "[0-9]{0," & decNum & "}$"
在这里,我需要验证

1) 整数值(点前)

2) 十进制值(点后)

3) 输入的整个长度

wholeNum = 30

decNum  = 20
例如:值为12345678901213456789012345678901234567890.123456789001234567890

根据我的代码,这两种情况都很好

但我需要补充一个条件,总长度应该是40

例如:您示例的可能输入:((30.10)或(20.20)或(25.15))

1) 12345678901213456789012345678901234567890.1234567890(总数应为40)

2) 123456789012134567890.123456789012134567890

3) 12345678900123456789012345.678901234567890

如何在我的代码中添加该条件


谢谢。

我会使用前瞻性断言:

regularExp = "^" & "(?=.{40}$)" & "[-]{0,1}[0-9]{0," & wholeNum & "}\" & DecSep & "[0-9]{0," & decNum & "}$"

假设您正在计算,包括点。

您能使用格式化工具吗?请尝试[0-9]*匹配0或更多次(或[0-9]+匹配1或更多次)。在正则表达式中。我无法输入任何字符。