Spec-Zone.ru › ColdFusion

reFind

Uses a regular expression (RE) to search a string for a pattern, starting from a specified position. The search is case-sensitive.It will return numeric if returnsubexpressions is false and a struct of arrays named "len", "match" and "pos" when returnsubexpressions is true.

reFind(reg_expression, string [, start] [, returnsubexpressions]) → returns any

  • CF
  • Lucee
  • BL 1.0.0+
  • See Also: find refindnocase findnocase rereplace

    Argument Reference

    reg_expression string
    Required

    string string
    Required

    A string or a variable that contains one. String in which to search.

    start numeric
    Default: 1

    returnsubexpressions boolean
    Default: false

    True: if the regular expression is found, the first array element contains the length and position, respectively, of the first match. If the regular expression contains parentheses that group subexpressions, each subsequent array element contains the length and position, respectively, of the first occurrence of each group. If the regular expression is not found, the arrays each contain one element with the value 0. False: the function returns the position in the string where the match begins. Default.
    Values:
    • true
    • false

    scope string
    Default: one

    CF 2016+ * one: returns the first value that matches the regex. * all: returns all values that match the regex.
    Values:
    • one
    • all

    Links more information about reFind

    • Regular Expressions in ColdFusion Howto - Learn about regex in CFML, written by Pete Freitag
    • Regular Expression Cheat Sheet - Lists the special characters and their meanings

    Examples
    Sample code invoking the reFind function

    Find an integer in a string

    This example uses reFind to locate an integer in a string, and returns the position of the integer in the string.

    reFind("[0-9]+", "test 123!")

    Expected Result: 6

    © 2012–present Foundeo, Inc. and the CFDocs contributors.
    Licensed under the MIT License.
    ColdFusion is a trademark of Adobe Systems Incorporated.
    https://cfdocs.org/refind

    Spec-Zone.ru

    Настройки Оффлайн Что нового Помощь О нас
    Spec-Zone .ru
    спецификации, руководства, описания, API