PowerApps 中的 HashTags 函数HashTags function in PowerApps

从文本字符串中提取井号标签 (#strings)。Extracts the hashtags (#strings) from a string of text.

说明Description

HashTags 函数扫描字符串中的井号标签。The HashTags function scans a string for hashtags. 井号标签以井号字符 (#) 开头,后跟以下任意组合:Hashtags start with a pound character (#), which is followed by any combination of:

  • 大写和小写字母uppercase and lowercase letters
  • 数字numerals
  • 下划线underscores
  • 货币符号(如 $)currency symbols (such as $)

HashTags 返回一个单列,此表包含字符串中的井号标签。HashTags returns a one-column table that contains the hashtags in the string. 如果字符串不包含井号标签,此函数将返回仅包含一个列的表。If the string contains no hashtags, the function returns a one-column table that's empty.

语法Syntax

HashTags( String )HashTags( String )

  • String - 必需。String - Required. 用于扫描井号标签的字符串。String to scan for hashtags.

示例Examples

分步操作Step by step

  1. 添加“文本输入”控件,将它命名为“Tweet”,然后在其中键入下面这句话:Add a Text input control, name it Tweet, and type this sentence into it:

    This #app is #AMAZING and can #coUnt123 or #123abc but not #1-23 or #$\*(#@")This #app is #AMAZING and can #coUnt123 or #123abc but not #1-23 or #$\*(#@")

  2. 添加垂直自定义库,并将其 Items 属性设置为此函数:Add a vertical custom gallery, and set its Items property to this function:

    HashTags(Tweet.Text)HashTags(Tweet.Text)

  3. 将“标签”控件添加到库模板中。Add a Label control to the gallery template.

    库将显示以下井号标签:The gallery shows these hashtags:

    • #app#app
    • #AMAZING#AMAZING
    • #coUnt123#coUnt123
    • #123abc#123abc
    • #1#1