mirror of
https://github.com/mastodon/mastodon-ios.git
synced 2024-12-16 10:48:49 +01:00
0c5b3a64cf
as defined here: https://github.com/mastodon/mastodon/blob/main/app/javascript/mastodon/features/compose/components/search.jsx#L280-L310
31 lines
847 B
Swift
31 lines
847 B
Swift
//
|
|
// MastodonRegex.swift
|
|
// Mastodon
|
|
//
|
|
// Created by MainasuK Cirno on 2021-5-14.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
public enum MastodonRegex {
|
|
/// mention, hashtag.
|
|
/// @...
|
|
/// #...
|
|
public static let highlightPattern = "(?:@([a-zA-Z0-9_]+)(@[a-zA-Z0-9_.-]+)?|#([^\\s.]+))"
|
|
/// 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
|
|
public static let emojiPattern = "(?:(^\\B:|\\s:)([a-zA-Z0-9_]+)(:\\B(?=\\s)))"
|
|
/// mention, hashtag, emoji
|
|
/// @…
|
|
/// #…
|
|
/// :…
|
|
public static let autoCompletePattern = "(?:@([a-zA-Z0-9_]+)(@[a-zA-Z0-9_.-]+)?|#([^\\s.]+))|(^\\B:|\\s:)([a-zA-Z0-9_]+)"
|
|
|
|
public enum Search {
|
|
public static let username = "^@?[a-z0-9_-]+(@[\\S]+)?$"
|
|
}
|
|
}
|
|
|