@@ -525,6 +525,18 @@ <h4>Powered by:</h4>
525525 resultDiv . style . display = 'block' ;
526526 }
527527
528+ const renderExample = ( str ) => {
529+ if ( str === '' ) {
530+ return '<i>the empty string</i>' ;
531+ } else {
532+ return `<code>${ encode ( str ) } </code>` ;
533+ }
534+ } ;
535+
536+ const renderExampleList = array => {
537+ return `<ul>${ array . map ( renderExample ) . map ( str => `<li>${ str } </li>` ) . join ( '' ) } </ul>` ;
538+ }
539+
528540 function showResultWithDiagram ( message , type , examples = null , hasValidationIssue = false ) {
529541 const resultDiv = document . getElementById ( 'result' ) ;
530542
@@ -545,21 +557,30 @@ <h4>Powered by:</h4>
545557
546558 // Add examples if provided
547559 if ( examples ) {
548- html += '<p>For example, '
549-
560+ html += '<p>Example strings matched by one RegExp but not the other:</p>'
561+ html += '<div style="display: flex; gap: 20px; margin-top: 15px;">' ;
562+
563+ // Left column for RegExp 1 examples
564+ html += '<div style="flex: 1;">' ;
550565 if ( examples . regex1Only && examples . regex1Only . length > 0 ) {
551- html += `RegExp 1 matches ` ;
552- html += examples . regex1Only . map ( str => `<code>${ encode ( str ) } </code>` ) . join ( ', ' ) ;
553- html += ' but RegExp 2 does not. ' ;
566+ html += `<p>
567+ <h4>RegExp 1 only</h4>
568+ ${ renderExampleList ( examples . regex1Only ) }
569+ </p>` ;
554570 }
555-
571+ html += '</div>' ;
572+
573+ // Right column for RegExp 2 examples
574+ html += '<div style="flex: 1;">' ;
556575 if ( examples . regex2Only && examples . regex2Only . length > 0 ) {
557- html += `RegExp 2 matches ` ;
558- html += examples . regex2Only . map ( str => `<code>${ encode ( str ) } </code>` ) . join ( ', ' ) ;
559- html += 'but RegExp 1 does not. ' ;
576+ html += `<p>
577+ <h4>RegExp 2 only</h4>
578+ ${ renderExampleList ( examples . regex2Only ) }
579+ </p>` ;
560580 }
561-
562- html += '</p>'
581+ html += '</div>' ;
582+
583+ html += '</div>' ;
563584 }
564585
565586 resultDiv . innerHTML = html ;
0 commit comments