Terenz Posted February 23, 2017 Share Posted February 23, 2017 (edited) Hello, my basic strings: (ABC - 9.00 x) (ABC-12:00) (ABC + 9.30 x) My final result i'd like to have is: -9 +12 +9.30 I need the decimal only if there are different from zero, i don't know if is possible with a regex this part or i need to do after. The symbol changes are + and - or . and : for the digits, sometimes there are spaces. Thanks for the help with this Edited February 23, 2017 by Terenz Nothing is so strong as gentleness. Nothing is so gentle as real strength Link to comment Share on other sites More sharing options...
jguinch Posted February 23, 2017 Share Posted February 23, 2017 (edited) One way : Local $aStrings = ["(ABC - 9.00 x)", "(ABC-12:00)", "(ABC + 9.30 x)", "(ABC - 22.35 x)", "(ABC + 07:02 x)", "(ABC + 14.00 x)"] For $i = 0 To UBound($aStrings) - 1 $number = StringRegExpReplace($aStrings[$i], ".*([+-])\h*(\d+)(?=[.:]\d{2})(?|([.:][^0]\d)|([.:]\d[^0])|[.:]00()).*", "$1$2$3") ConsoleWrite($aStrings[$i] & @TAB & " => " & @TAB & $number & @CRLF) Next Edited February 23, 2017 by jguinch Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
Terenz Posted February 24, 2017 Author Share Posted February 24, 2017 (edited) Woa @jguinch really cool! I need just one step more, i did't notice yesterday but exist a chance that string is without numbers: (ABC) It that case i need to return 0. Many thanks! Edited February 24, 2017 by Terenz Nothing is so strong as gentleness. Nothing is so gentle as real strength Link to comment Share on other sites More sharing options...
jguinch Posted February 24, 2017 Share Posted February 24, 2017 easy : It Not @extended The $number = 0 Terenz 1 Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now