例如,我们在javaScript中有下一个字符串
CREATE SEQUENCE SQ_ARAN_SQ_ARQUIVO_ANEXO;
CREATE OR REPLACE FUNCTION UFC_SPSW_DISP_COMPOSICAO(p_id_composicao IN NUMBER) RETURN NUMBER
IS
retorno NUMBER:= 0;
numeroItens NUMBER;
temDefinicao BOOLEAN := false;
CURSOR item_cur is
select idc.itdc_sq_item_definicao_composi, idc.insu_sq_insumo, idc.comp_sq_composicao, idc.itdc_nr_coeficiente, idc.COMP_DS_COMPOSICAO, idc.comp_sq_composicao_pai
from item_definicao_composicao idc;
BEGIN
FOR item_rec IN item_cur LOOP
temDefinicao := true;
IF (item_rec.itdc_nr_coeficiente is null) THEN
RETURN null;
ELSE
IF (item_rec.insu_sq_insumo is null) THEN
numeroItens := UFC_SPSW_DISP_COMPOSICAO(nvl(item_rec.comp_sq_composicao_pai, item_rec.comp_sq_composicao));
else
retorno := retorno + 1;
END IF;
END IF;
END LOOP;
IF (temDefinicao = false) THEN
RETURN 0;
END IF;
RETURN retorno;
END;
CREATE SEQUENCE SQ_CALC_SQ_CALCULO;
我怎么能得到55,5作为数字?
答案 0 :(得分:1)
这取决于您对数字的假设,但对于示例和很多情况,这应该有效:
var str = "abc,de 55,5gggggg,hhhhhh";
var match = /\d+(,\d+)?/.exec(str);
var number;
if (match) {
number = Number(match[0].replace(',', '.'));
console.log(number);
} else console.log("didnt find anything.");

答案 1 :(得分:0)
var str = "abc,de 55,5gggggg,hhhhhh"
var intRegex = /\d+((.|,)\d+)?/
var number = str.match(intRegex);
console.log(number[0]);

答案 2 :(得分:0)
https://jsfiddle.net/jiteshsojitra/5vk1mxxw/
var str = "abc,de 55,5gggggg,hhhhhh"
str = str.replace(/([a-zA-Z ])/g, "").replace(/,\s*$/, "");
if (str.match(/,/g).length > 1) // if there's more than one comma
str = str.replace(',', '');
alert (str);