Matches: 100.0 | 100.00 | 100.05000
Does not match: 100 | 100.05 | 123
What I have so far is:
Code: Select all
(?(\d+\.(0+))\.0+$|0+$)Moderator: General Moderators
Code: Select all
(?(\d+\.(0+))\.0+$|0+$)Code: Select all
$number = rtrim($number, '0.');Code: Select all
Friend Function SplitPosAcc(ByVal input As String) As String
Dim re As New Regex("regex_string")
Return re.Replace(input, "").Trim
End Function
sNumVal = numPosAcc.Value.ToString 'get the accuracy value in raw form
sNumVal = (SplitPosAcc(sNumVal))Code: Select all
sNumVal = sNumVal.TrimEnd("0"c)It would have been nice to know that before...buldir wrote:Thanks for the reply, feyd. I am not using php, but VB .NET to replace the trailing zeros with nothing
Code: Select all
#^(?:(\d+)(?:\.0*)?|(\d+\.\d+?)0*)$#Code: Select all
[feyd@home]>php -r "$a = array('100', '100.00', '105.', '105', '150', '150.00060'); foreach($a as $s){ preg_match('#^(?:(\d+)(?:\.0*)?|(\d+\.\d+?)0*)$#', $s, $match); var_dump($match); }"
array(2) {
[0]=>
string(3) "100"
[1]=>
string(3) "100"
}
array(2) {
[0]=>
string(6) "100.00"
[1]=>
string(3) "100"
}
array(2) {
[0]=>
string(4) "105."
[1]=>
string(3) "105"
}
array(2) {
[0]=>
string(3) "105"
[1]=>
string(3) "105"
}
array(2) {
[0]=>
string(3) "150"
[1]=>
string(3) "150"
}
array(3) {
[0]=>
string(9) "150.00060"
[1]=>
string(0) ""
[2]=>
string(8) "150.0006"
}Code: Select all
(?<=\d+\.\d+)0+$|\.0+$