refac: input commands

This commit is contained in:
Timothy J. Baek
2024-08-23 14:31:39 +02:00
parent 64c0157271
commit 591962d906
7 changed files with 304 additions and 331 deletions

View File

@@ -288,6 +288,20 @@ export const findWordIndices = (text) => {
return matches;
};
export const removeLastWordFromString = (inputString, wordString) => {
// Split the string into an array of words
const words = inputString.split(' ');
if (words.at(-1) === wordString) {
words.pop();
}
// Join the remaining words back into a string
const resultString = words.join(' ');
return resultString;
};
export const removeFirstHashWord = (inputString) => {
// Split the string into an array of words
const words = inputString.split(' ');