Home > Enterprise >  Inserting Characters into NetSuite Saved Search Results Column
Inserting Characters into NetSuite Saved Search Results Column

Time:10-05

I'm trying to find a way to insert line breaks into certain places in a text area column in a NetSuite saved search. In some instances this "comments" value contains data separated by line breaks with each line started by a digit followed by a period. The issue is that when this data is presented to be included as part of the results, the line breaks are removed, causing everything to run together. For the most part, I've been able to at least find where I need to insert the line breaks with the following:

REGEXP_REPLACE({notes}, '\d{1,2}\.', '<br />', 3, 0, 'i')

The problem, though, is that replaces all of the numerical "bullet points" except for what may be at the very first (typically '1.'), which is not desirable. Is there a way to re-insert these line breaks and keep the numerical bullets?

CodePudding user response:

You can re-use the matched text in the replacement pattern through backreferences:

REGEXP_REPLACE({notes}, '(\d{1,2}\.)', '<br />\1', 3, 0, NULL)

This will start searching for a match, case-sensitively (note I replaced 'i' with NULL since digits and a dot char are casefree chars), from the third position in the string, and will replace all matches (due to the 0 occurrence argument) with the same text as matched with <br /> prepended to it.

  • Related