Elster
1
Hello dear community,
I would like to solve the current problem of my regex in combination with command SourceExtract. Currently Kantu just extracts the 6 instead of 26.
Furthermore the numbers to extract will differ from 0 to 999.
regex=(1 - .[von].*(\d+)@1,2
Do you have any idea to solve my problem?
Thank you in advance for your help!
ulrich
2
Does this regex work ok on regex101?
Elster
3
Yes it does�
As far as I know one has to use following Syntax:
regex=[(1 -]\d+[von]*\d+@1,2
But the error is still ocurring.
I use alternative solution better of regex
To extract part of text you can use simple javascript to split text and working like a charm
{
âCommandâ: âexecuteScript_Sandboxâ,
âTargetâ: âreturn ${VAR}.split(âXXXâ)[0]â,
âValueâ: âFirstLineâ
}
You split the multiple parts and use the part you interested
Elster
5
Thanks for your hint using javascript. I need further help to understand you.
I think I have to use match() in combination with my regex, or is that the wrong way to get the 26 of my example?
Itâs simple with my code you can split infinite times and take the desired part
Macro code
{
"Name": "Split_Function",
"CreationDate": "2020-4-22",
"Commands": [
{
"Command": "store",
"Target": "(1 - 26 von 26)",
"Value": "Col"
},
{
"Command": "executeScript_Sandbox",
"Target": "return ${Col}.split(\"von \")[1];",
"Value": "First_Part"
},
{
"Command": "echo",
"Target": "${First_Part}",
"Value": ""
},
{
"Command": "executeScript_Sandbox",
"Target": "return ${First_Part}.split(\")\")[0];",
"Value": "Second_Part"
},
{
"Command": "echo",
"Target": "${Second_Part}",
"Value": ""
}
]
}
Result log
[status]
Playing macro Split_Function
[info]
Executing: | store | (1 - 26 von 26) | Col |
[info]
Executing: | executeScript_Sandbox | return ${Col}.split("von ")[1]; | First_Part |
[info]
Executing: | echo | ${First_Part} | |
[echo]
26)
[info]
Executing: | executeScript_Sandbox | return ${First_Part}.split(")")[0]; | Second_Part |
[info]
Executing: | echo | ${Second_Part} | |
[echo]
26
[info]
Macro completed (Runtime 1.74s)
1 Like
I found the mistake in my regex
The solution looks like this:
regex=(1 - .[von]@1,1