Skip to main content
nID='1' nOperTime='2022-07-31 23:51:56' szUserName='default' EventType='Save Config' Remarks='Saved -P2P- config.IP:Local LoginUsername:default Group Name:user' 

I want to split this into nID, nOperTime, szUserName and EventType

 

I've tried using the KeyValueAttributeCreator transformer to do this with:-

 

Key,Value Delimiter: =

Key,Value Separator: <a single space>

 

After this runs I see thousands of columns created with name 1,2,3,4... which appear to be the value of nID rather than the key. I wonder if the issue is the quotes and if so is there a solution that will see quoted fields as a single value?

@davebarter​ There's a StringSearcher regex solution here but I can't see it:

(\\w+='3\\d\\-\\s:]+' )

gets the first name/value (nID='1' ), but I can't see how to make the sub-expression to repeat for subsequent name value pairs. If someone can figure out how todo that then the StringSearcher with Subexpression List Name will give you what you need I think


If you use a string replacer with some regex to replace all the spaces outside of quotes with pipe | or similar you can use that as the Delimiter int he KeyValueAttributeCreator transformer

 

think this regex should work

\s(?=(?:x^\']*'l^\']*\')*p^\']*$)

 


@davebarter​ There's a StringSearcher regex solution here but I can't see it:

     (\w+='p\d\-\s:]+' )

gets the first name/value (nID='1' ), but I can't see how to make the sub-expression to repeat for subsequent name value pairs.  If someone can figure out how todo that then the StringSearcher with Subexpression List Name will give you what you need I think

If you wanted to use this approach to get a list you could use this regex

(\w+\=\'a^\']+\'?)

Which would give you each element as a list value

image


If you don't need the process to be dynamic and always know the value of your keys you could also do something like thisimage 


@davebarter​ Thanks @ebygomm​ for the clever regex. I've attached an example workspace based on that approach. FME 2021.2


Thanks All!

@Mark Stoakes​ @ebygomm​ that works a treat


Reply