Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
foreach and replace nested
#6
succeed!

thank you so much!

Macro Macro9
Code:
Copy      Help
str s=
;function A([Paragraph]$p1, [Paragraph]$p2){
;,'{A}'
;}
;function BB([Paragraph]$p1){
;,'{BB}'
;}
;function CCC(){
;,'{CCC}'
;}
;
;function Main([string[]]$args)
;{
;,$A($p1, $p2)
;,$BB($p1)
;,$CCC()
;}

str pattern="function ([a-zA-Z_][a-zA-Z0-9_]*\().*\)"
str d
ARRAY(str) a
findrx(s pattern 0 4 a)
for int'i 0 a.len
,d.addline(F"${a[1 i]}")

str e
foreach str's_ s
,foreach str'd_ d
,,if(findrx(s_ F"\Q{d_}\E") != -1)
,,,s_.replacerx("\(" " ")
,,,s_.replacerx("\)" "")
,,,s_.replacerx("," "")
,,,s_.replacerx("^(\s)\$" "$1")
,e.addline(s_)

out e

QM is very legendary, very classic  Smile
With LA, there may be more code


Messages In This Thread
foreach and replace nested - by Davider - 10-23-2022, 07:57 AM
RE: foreach and replace nested - by Davider - 10-23-2022, 11:45 AM
RE: foreach and replace nested - by Gintaras - 10-23-2022, 11:58 AM
RE: foreach and replace nested - by Davider - 10-23-2022, 12:00 PM
RE: foreach and replace nested - by Gintaras - 10-23-2022, 12:05 PM
RE: foreach and replace nested - by Davider - 10-23-2022, 12:14 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)