Results 1 to 3 of 3

Thread: Question About query

  1. #1
    Join Date
    Jul 2020
    Posts
    2

    Question About query

    set @Provs: " "
    SET @Provs=(CASE WHEN @Provs="" THEN "^" ELSE CONCAT('^',REPLACE(@Provs,"|","$|^"),"$") END);

    Can anyone please explain whats the purpose of the metacharacters ^ $ in this query.

    Thanks

  2. #2
    Join Date
    Apr 2011
    Location
    Largo, FL.
    Posts
    78
    A Google search shows me the following:

    "^" - a caret is called an "anchoring operator," and matches the beginning of a string. The caret may also mean "not," which is at best confusing.
    "$" - a dollar sign is another anchoring operator and matches only the end of a string.
    "." - the period matches anything and is called the "match any character" operator. Many would call this a "wildcard" match character.
    + matches one or more repetitions of the preceding RE
    * matches zero or more repetitions of the preceding RE
    ? matches zero or one repetition of the preceding RE


    I would think the metacharacters are universal.

  3. #3
    Join Date
    Jul 2020
    Posts
    2
    Thankyou Steve for your quick respnse !!

    I am still not able to understand how the case statement is running in this statement. Any help in understanding this would be really helpul

    If
    set @Provs: 'A|B|C'
    SET @Provs=(CASE WHEN @Provs=" " THEN "^" ELSE CONCAT('^',REPLACE(@Provs,"|","$|^"),"$") END);

    If the variable has been set to A|B|C then how would the statement run.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •