mizzkey/src/mfm/parse/elements/search.ts
2018-08-15 20:27:36 +09:00

20 lines
332 B
TypeScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* Search
*/
export type TextElementSearch = {
type: 'search'
content: string
query: string
};
export default function(text: string) {
const match = text.match(/^(.+?)( | )(検索|\[検索\]|Search|\[Search\])(\n|$)/i);
if (!match) return null;
return {
type: 'search',
content: match[0],
query: match[1]
};
}