html - groovy - displaying a String by using <br> -


i have string contains several values displayed in table

def mystring = "123,234;12904,1989,8709,6745" 

i replace each value link

<td>${mystring.replaceall(/[0-9]+/) { m ->  '<a href="../mylink>'+m+'</a>'}}</td>  

the result is:

123,234;12904,1989,8709,6745,.... 

i constated string can long, added 'br' after each value:

<td>${mystring.replaceall(/[0-9]+/) { m ->  '<a href="../link>'+m+'<br></a>'}.replaceall(",","")}</td>  

the result is:

123 234 12904 1989 8709 6745 ... 

the result not suit me.

the best solution me add 'br' after third value have like:

123,234;12904 1989,8709,6745 

is there possibility have display code have?

you try:

mystring.findall( /[0-9]+/ )                       // extract numeric elements         .collect { "<a href='../mylink'>$it</a>" } // create link each         .collate( 3 )                              // group them 3s         .collect { it.join() + '<br>' }            // join each 3 <br>         .join( '\n' )                              // join lines 

or

mystring.findall( /[0-9]+/ )                       // extract numerics         .collect { "<a href='../mylink'>$it</a>" } // create  link each         .collate( 3 )*.join()                      // group 3s , join them         .join( '<br>' )                            // split each <br> 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -