Just wanna share my code that extracts only numbers, alphabets from a string using regex. Irrelevant character will be ignored.
Maybe there is a neater code
Maybe there is a neater code
function cExtractAlphabets(cStr)
local a_ := hb_regexAll("[A-Za-z ]", cStr), cRet := "", aChar
if a_ != nil
for each aChar in a_
cRet += aChar[1]
next
endif
return cRet // returns alphabet and space onlyfunction cExtractNum(cStr)
local a_ := hb_regexAll("\d{1,}", cStr), cNum := "", aDigit
if a_ != nil
for each aDigit in a_
cNum += aDigit[1]
next
endif
return cNumFWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
BCC5.82/BCC7.3
xHarbour/Harbour