sree161 Posted August 29, 2017 Share Posted August 29, 2017 Hi, I have some alphanumeric text Eg:x=10kms. I need only 10 from the statement. Is there any command to fetch only number as above?? Thanks in advance, sreee161 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 29, 2017 Moderators Share Posted August 29, 2017 sree161, You need to use a RegEx: #include <Array.au3> $sText = "x=10kms" $aRet = StringRegExp($sText, "\d{1,}", 3) _ArrayDisplay($aRet, "", Default, 8 That will extract any numeric elements found within the string. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
sree161 Posted August 29, 2017 Author Share Posted August 29, 2017 29 minutes ago, Melba23 said: sree161, You need to use a RegEx: #include <Array.au3> $sText = "x=10kms" $aRet = StringRegExp($sText, "\d{1,}", 3) _ArrayDisplay($aRet, "", Default, 8 That will extract any numeric elements found within the string. M23 Thanks for the help.... How can i use this number for further processing. i want to use it as integer. I tried int($aRet) But it soesn't work can u help??? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 29, 2017 Moderators Share Posted August 29, 2017 sree161, The return from StringRegExp when looking for matches is an array (the use of _ArrayDisplay should have given you a clue!) so you need to reference the array elements: Int($aRet[0]) should do the trick. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area 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