0

I am using XSL to render my data on screen using some basic JS. I am trying to take some string from db and show it on screen inside my <span>. The span will be editable so that user can amend the data. Everything is working fine except when the user tries to add new line in the data from the screen the data gets concatenated with a <br>. I can view this value using alert in JS. I know XSLT 1.0 doesn't support regex so I am thinking is there any workaround to achieve what i want. Below are the codes and the current output and the desired output to understand my Question better. Any suggestion or is appreciated.Thanks in advance!

XSL

<table cellpadding="0" cellspacing="0" width="100%" >
    <tr>
        <xsl:choose>
            <xsl:when test="//faml/response/mtcresponsedto/terms_conditons">
                <xsl:for-each select="//faml/response/mtcresponsedto/terms_conditons/tandcdto">
                    <div class="carousel">
                        <div class="frames">
                            <td style="padding-right: 10px">
                                <xsl:variable name="txn_desc">
                                    <xsl:value-of select="termsandconditions"/>
                                </xsl:variable>
                                <div id='item1'>
                                    <span class="pre" contentEditable="true" >
                                        <xsl:value-of select="termsandconditions"/>
                                    </span>
                                </div>
                            </td>
                        </div>
                    </div>
                </xsl:for-each>
            </xsl:when>
            <xsl:otherwise></xsl:otherwise>
        </xsl:choose>
    </tr>
</table>

JS

var flag = $('#item1 span').html();

alert(flag.replace(/<br[^>]*>/g, "\n"));

Current Output in alert

Hi I am <br><br> demonstration.

Desired Output

Hi I am 


Demonstration
Saurav
  • 47
  • 9
  • Does this answer your question? [New line in JavaScript alert box](https://stackoverflow.com/questions/1841452/new-line-in-javascript-alert-box) – Bren Jul 10 '20 at 05:13
  • No i guess you didnt understood my question correctly. I am getting value as ```Some String

    ``` and i want ```
    ``` to replace it with new line. The question which you mentioned is totally different from my situation.
    – Saurav Jul 10 '20 at 05:20
  • **Please do not post the same question twice:** https://stackoverflow.com/questions/62815151/how-to-use-regex-in-xslt-1-0 – michael.hor257k Jul 10 '20 at 05:32

0 Answers0