Log in
Log into community
Share feedback, ideas and get community help
View all posts
Related posts
Did this answer your question?
😞
😐
😃
Powered by
Hall
Inactive
Updated 11 months ago
0
Follow
How to Use Regular Expressions
How to Use Regular Expressions
Inactive
0
Follow
M
Michael
11 months ago
·
I need to identify a pattern in regex and save it in a variable, how to
Attachment
M
B
3 comments
Share
Open in Discord
M
Michael
11 months ago
Basic I need this, how to salve the output in a variable ?
Attachment
M
Michael
11 months ago
Solved with this code:
function extrairCPFDaString(texto) {
const regexCpf = /\b\d{11}\b/;
const resultado = texto.match(regexCpf);
if (resultado) {
const cpfEncontrado = resultado[0];
return cpfEncontrado;
} else {
return "CPF não encontrado no texto.";
}
}
const texto = "CPF: 12234455566\nWhatsApp: +556791440690";
const resultadoExtracao = extrairCPFDaString(texto);
return (resultadoExtracao);
Attachment
B
Baptiste
11 months ago
Yep, good job!
Add a reply
Sign up and join the conversation on Discord
Join on Discord