How to repalce a string with specific format by SQL

huangbin chen June 21, 2022

I would like to change some specific string to a specific format like "line break" or "bullet" or "color text".

 

Example:

Original Table:

WWMemberHighlight
WW25MemAGREEN || ProjectA || Description-A
WW25MemBRED || ProjectB || Description-B

 

SQL Expected result:

WWMemberHighlight
WW25MemA

GREEN

  • ProjectA
    • Description-A
WW25MemB

RED

  • ProjectB
    • Description-B

 

Experimental but cannot work as expected:

  • REPLACE(T1.'Highlight',"||",FORMATWIKI("\n"+ "* " + "\n") ) as 'Hightlight-formated'

 

continuous following up from this question:

how to merge row cell by SQL

 

Thanks

1 answer

1 accepted

6 votes
Answer accepted
Katerina Kovriga {Stiltsoft}
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 21, 2022

Hi @huangbin chen ,

We can suggest the following SQL query for your table:

SELECT *,
FORMATWIKI(REPLACE(T1.'Highlight',"||", "\n"+ "* " + "\n")) as 'Hightlight-formated'
FROM T*

Tue 5-1.png

I'm afraid that the multiple-level bullets that are shown on your screenshot are not possible to implement.

huangbin chen June 21, 2022

Thanks @Katerina Kovriga {Stiltsoft} ,

Is is possible to have "color text" or "bold type" at specific separate char?

Source Example: Green || Project A >> Description-A

Expected result:

Green

  • Project A
  • Description-A

Or even mark "Green" as with color green.

Katerina Kovriga {Stiltsoft}
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 21, 2022

The FORMATWIKI function works with the contents of the cell as a whole unit: you can color/make bold all the text but not specific strings (that are also different for every cell).

Like # people like this

Suggest an answer

Log in or Sign up to answer