EvalueTonSavoir/client/src/services/QuestionService.ts

26 lines
703 B
TypeScript
Raw Normal View History

2024-03-29 20:08:34 -04:00
export class QuestionService {
static getImage(text: string) {
const imageUrlMatch = text.match(/<img[^>]+>/i);
if (imageUrlMatch) {
return imageUrlMatch[0];
}
return '';
}
static getImageSource = (text: string): string => {
let imageUrl = text.replace('<img ', '');
imageUrl = imageUrl.replace('>', '');
return imageUrl;
};
static ignoreImgTags(text: string): string {
if (text.includes('<img')) {
const imageUrlMatch = text.match(/<img[^>]+>/i);
if (imageUrlMatch) {
text = text.replace(imageUrlMatch[0], '');
}
}
return text;
}
}