I am looking for Regex to extract the parameters of a SAP Form Routine.
The Form routine signature looks like the following:
FORM get_vbrk_data USING cs_bil_number TYPE VBELN CHANGING cs_vbrk TYPE vbrk cs_vbak TYPE vbak.
Challenge here is to get the name of the FORM routine -> get_vbrk_data
... AND the parameters:
USING -> cs_bil_number TYPE VBELN
CHANGING -> cs_vbrk TYPE vbrk AND cs_vbak TYPE vbak
The perfect format would be an result array with the following format:
[ "get_vbrk_data", "USING", "cs_bil_number", "TYPE", "VBELN", "CHANGING", "cs_vbrk", "TYPE", "vbrk", "cs_vbak", "TYPE", "vbak" ]
I tried to start with the following Regex:
\b(?:USING|CHANGING).*
But I am not able to process further.
CodePudding user response:
Observing your perfect format, you don't actually extract the parameters, but rather simply divide the Form routine without the leading FORM
and the trailing .
into its substrings:
s = "FORM get_vbrk_data USING cs_bil_number TYPE VBELN CHANGING cs_vbrk TYPE vbrk cs_vbak TYPE vbak."
console.log(s.slice(5, -1).split(' '))