Get value after each last colon

后端 未结 3 1478
忘掉有多难
忘掉有多难 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:41

    Is there an easy way on will I get the value after each last colon because there's so many keys[...]

    Yes. You can use RegEx matching.
    In the following template regex-group(2) contains the string after the second/(last) colon. And regex-group(1) contains the key.

    
        
            
                
                    ( --- )
    
                
            
        
    
    

    Partial output:

    (20 --- PmtReferenceID000012)
    (21 --- Not used)
    (25 ---  PHMNLBICXXX/Account00010203)
    (28c --- 00001/0001 (The 'c' in :28 can be either in upper or lower case))
    

    With that you can create a key/value Dictionary that creates the tags around the text.

    Like this:

    • Key: 20, Value: ABCD
    • Key: 21, Value: EFGH
    • ...

    For example: you can create a variable inside the XSL file to store the mapping:

    
      
    
      
        ABCD
        EFGH
        IJKL
        MNOP
      
    
      
        
            
        
      
    
      
        
            
                
                    
                
            
        
      
    
    

    Full output:

    
    
       PmtReferenceID000012
       Not used
        PHMNLBICXXX/Account00010203
       00001/0001 (The 'c' in :28 can be either in upper or lower case)
    
    

    Or you could literally outsource the mapping and create a separate file for them...

提交回复
热议问题