Get value after each last colon

后端 未结 3 1483
忘掉有多难
忘掉有多难 2021-01-26 07:14

I need to get the value of each data after the last colon. For example, I have this file:


:20:PmtReferenceID000012
:21:Not used
:25: PHMNLBICXXX/Acc         


        
3条回答
  •  一向
    一向 (楼主)
    2021-01-26 07:43

    In XSLT 3.0 you could write templates for the different strings e.g.

    
    
    
        
    
        
            
                
            
        
    
        
            
                
            
        
    
        
            
                
            
        
    
        
            
                
            
        
    
        
            
                
            
            
    
    

    With Saxon 9.8 or Altova XMLSpy/Raptor that does the job and outputs

    
       PmtReferenceID000012
       Not used
        PHMNLBICXXX/Account00010203
       00001/0001
    
    

    (for the input

    
    :20:PmtReferenceID000012
    :21:Not used
    :25: PHMNLBICXXX/Account00010203
    :28c:00001/0001
    
    

    )

    As an alternative, instead of tokenizing and processing strings you could use the analyze-string function and match on the returned fn:match elements:

    
    
    
        
    
        
            
                
            
        
    
        
            
                
            
        
    
        
            
                
            
        
    
        
            
                
            
        
    
        
            
                
            
        
    
    
    

    Finally, taking up the idea of a map parameter to define the element names the second solution can be shortened to

    
    
    
        
    
        
    
        
            
                
            
        
    
        
            
                
            
        
    
    
    

提交回复
热议问题