Use XSLT to mark up text matching regex?

前端 未结 3 1302
梦谈多话
梦谈多话 2021-01-20 00:13

I am trying to use XSLT 2.0 (Saxon-PE 9.6) on an HTML document to create tags that surround all contiguous runs of characters from a specified non-Latin Unicode block (space

3条回答
  •  离开以前
    2021-01-20 00:40

    This should work (some comments after the code):

    XSLT 2.0

    
        
              
        
        
              
        
    
    
    • the regex is the one from your second try (as it was correctly matching only the Hindi text fragments!), just with parentheses around the first part
    • the matching-substring branch puts the span around the Hindi text
    • the non-matching-substring branch just returns the unmodified "normal" text substring (you were returning the whole text!)

提交回复
热议问题