I have the following problem that I have not been able to solve for several hours:
What I want to do is that when I receive a string, identify a pattern in said string and be able to use it later, for example when receiving the text:
"Hello this is an example message, the hashtag of the day is #Phone, you can use it wherever you want"
what I want to do is identify that #Phone and extract it from all that text and for example then be able to make a console.log()
of that word that is with the #. So that the result of the console.log is only Phone, for example, or the data that has the #
I have the following code:
const prefix = "#";
client.on("message", function(message) {
if (!message.content.includes(prefix)) return;
const commandBody = message.content.slice(prefix.length);
const args = commandBody.split(' ');
const command = args.shift().toUpperCase();
console.log(command)
});
This what returns me is the first element of the text without its first letter, in the case that the text is "Hello, how are you !try this", what it shows is only "ello", and I need it to only show " try"