mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-23 05:12:39 +00:00
@@ -67,6 +67,14 @@ export const getNanoid = (size = 12) => {
|
||||
/* Custom text to reg, need to replace special chats */
|
||||
export const replaceRegChars = (text: string) => text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
||||
|
||||
export const getRegQueryStr = (text: string, flags = 'i') => {
|
||||
const formatText = replaceRegChars(text);
|
||||
const chars = formatText.split('');
|
||||
const regexPattern = chars.join('.*');
|
||||
|
||||
return new RegExp(regexPattern, flags);
|
||||
};
|
||||
|
||||
/* slice json str */
|
||||
export const sliceJsonStr = (str: string) => {
|
||||
str = str.replace(/(\\n|\\)/g, '').replace(/ /g, '');
|
||||
|
Reference in New Issue
Block a user