How can I get the function "-> (" xxx "," xxx ")" at the end of some text
I want to get one or more ->func(xxx,xxx)at the end of a piece of code.
They can be like this:
any code any code ->func(xxx)
or
any code any code
->func()
or
any code any code
-funcA()->funcB(xxx)
or
any code any code
->funcA()
->funcB(xxx)
or mix them:
o.start_time = obj.s;
o.repair_type -> obj.r;
o.limit -> obj.l;->god("('\"\"')") ->fox(,'->')
->egg()->dog(,'c')
->cat(,'b')-> banana(,'a"\'\(\)\'->"()') -> apple(,'a')
In this code I want:
plan A
- get a substring
apple(,'a') - remove
-> apple(,'a') - get a substring
banana(,'a"\'\(\)\'->"()') - remove
-> banana(,'a"\'\(\)\'->"()') - get a substring
cat(,'b') - remove
->cat(,'b') - get a substring
dog(,'c') - remove
->dog(,'c') - get
egg() - remove
->egg() - get
fox(,'->') - remove
->fox(,'->') - get
god("('\"\"')")god("('\"\"')") - remove
->god("('\"\"')") - Over
- get a substring
plan B:
- get and delete
->cat(,'b')-> banana(,'a"\'\(\)\'->"()') -> apple(,'a')- get a substring
apple(,'a') - remove
-> apple(,'a') - get a substring
banana(,'a"\'\(\)\'->"()') - remove
-> banana(,'a"\'\(\)\'->"()') - get a substring
cat(,'b') - remove
->cat(,'b')
- get a substring
- get and delete
->egg()->dog(,'c')- get a substring
dog(,'c') - remove
->dog(,'c') - get
egg() - remove
->egg()
- get a substring
- get and delete
->god("('\"\"')") ->fox(,'->')- get
fox(,'->') - remove
->fox(,'->') - get
god("('\"\"')")god("('\"\"')") - remove
->god("('\"\"')")
- get
- Over
- get and delete
Now, I'm trying to planB with these two RegEx, but not good enough:
loop
if match "\R\s*->\s*(.+)$"
get substring and remove
loop substring
if match "(?:(?<=\)).)*\s*->\s*(((?!->).)*)$"
push substring2 to arr
remove substring2
else
break
else
break
I don't think regular expression is the last resort to match what you need, but it can be used for a one-time task.
PCRE , . , (...)
(?:((?(3)\s*|\R*)->\s*([\w.]*(\((?>'[^'\\]*(?:\\.[^'\\]*)*'|"[^"\\]*(?:\\.[^"\\]*)*"ββ|[^"'()]++|(?3))*\)))))+\s*\z
:
(?:((?(3)\s*|\R*)->\s*([\w.]*(\((?>'[^'\\]*(?:\\.[^'\\]*)*'|"[^"\\]*(?:\\.[^"\\]*)*"ββ|[^"'()]++|(?3))*\)))))+- 1 :(?(3)\s*|\R*)- , , 3, 0+, 3 , 0+ (\R*), 3 ββ( , )->\s*-->, 0+([\w.]*)- ( 1, ) 0 + -//(\((?>'[^'\\]*(?:\\.[^'\\]*)*'|"[^"\\]*(?:\\.[^"\\]*)*"|[^"'()]++|(?1))*\))- 1\(-((?>'[^'\\]*(?:\\.[^'\\]*)*'|"[^"\\]*(?:\\.[^"\\]*)*"|[^"'()]++|(?3))*- ('[^'\\]*(?:\\.[^'\\]*)*') ("[^"\\]*(?:\\.[^"\\]*)*")(...)([^"'()]++|(?3),(?3)3).\)-)
\s*\z- 0+ whitespace\s*\z.