I am working on a function that is designed to clean strings, specifically two types of strings:
"SATISFACTION._IS1.TOUTES_SITUATIONS.current_month_note"
and "SATISFACTION._IS1.TOUTES_SITUATIONS.note"
.
PS Just to clarify, TOUTES_SITUATIONS
is a variable.
What I need to extract from these strings is "TOUTES_SITUATIONS"
Below is the code snippet I have:
const extractSituation: Function = (sentence: string): string => {
return sentence.substring(
sentence.lastIndexOf('1.') + 2,
sentence.lastIndexOf('.n'),
);
};
Currently, this code only works for the string
"SATISFACTION._IS1.TOUTES_SITUATIONS.note"
but not "SATISFACTION._IS1.TOUTES_SITUATIONS.current_month_note"
Can you suggest a way to handle both types of strings effectively?