2021-05-14 14:02:59 +02:00
|
|
|
//
|
|
|
|
// MastodonRegex.swift
|
|
|
|
// Mastodon
|
|
|
|
//
|
|
|
|
// Created by MainasuK Cirno on 2021-5-14.
|
|
|
|
//
|
|
|
|
|
|
|
|
import Foundation
|
|
|
|
|
2021-07-19 11:12:45 +02:00
|
|
|
public enum MastodonRegex {
|
2021-05-14 14:02:59 +02:00
|
|
|
/// mention, hashtag.
|
|
|
|
/// @...
|
|
|
|
/// #...
|
2021-07-19 11:12:45 +02:00
|
|
|
public static let highlightPattern = "(?:@([a-zA-Z0-9_]+)(@[a-zA-Z0-9_.-]+)?|#([^\\s.]+))"
|
2021-05-14 14:02:59 +02:00
|
|
|
/// emoji
|
|
|
|
/// :shortcode:
|
|
|
|
/// accept ^\B: or \s: but not accept \B: to force user input a space to make emoji take effect
|
|
|
|
/// precondition :\B with following space
|
2021-07-19 11:12:45 +02:00
|
|
|
public static let emojiPattern = "(?:(^\\B:|\\s:)([a-zA-Z0-9_]+)(:\\B(?=\\s)))"
|
2021-05-18 08:25:32 +02:00
|
|
|
/// mention, hashtag, emoji
|
|
|
|
/// @…
|
|
|
|
/// #…
|
|
|
|
/// :…
|
2021-07-19 11:12:45 +02:00
|
|
|
public static let autoCompletePattern = "(?:@([a-zA-Z0-9_]+)(@[a-zA-Z0-9_.-]+)?|#([^\\s.]+))|(^\\B:|\\s:)([a-zA-Z0-9_]+)"
|
2021-05-14 14:02:59 +02:00
|
|
|
}
|