Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Gets the content between two tags
#6
while this is not a member function could be made into a function
shown here as a sub function for simplicity.
also shows how to fix #1
 
Code:
Copy      Help
_s=
;public static void Main(string[] args)
;{
;;#if A
;;;;;part1
;;;;;part1
;#endif
;
;part
;part
;
;#if V
;;;;;part2
;;;;;part2
;;;;;part2
;#endif
;
;part
;part
;
;#if C
;;;;;part3
;;;;;part3
;#endif
;}

out
;;;keep these two tags and output them together
str a1
sub.Match(_s a1 1)
out a1
out "-------------------------------------------------"
;;output only whats inbetween
str a2
sub.Match(_s a2 0)
out a2
;; delete (#if...#endif)
out "-------------------------------------------------"
_s.replacerx("#if.*(?s)(.*?)#endif" "")
_s.replacerx("(?:(?:(?!\n)\s)*\n){2,}" "[]")
out _s



#sub Match
function ~s ~&s2 mode
;;mode 1=output #if #endif everything in between. 0=output only whats inbetween

str s1;int t1
if mode&1
,foreach s1  s
,,if(matchw(s1 "*#if*")) t1=1;
,,if(t1=1) s2.addline(s1 1)
,,if(matchw(s1 "*#endif*")) t1=0;
else
,foreach s1  s
,,if(matchw(s1 "*#if*")) t1=1; continue
,,if(matchw(s1 "*#endif*")) t1=0; continue
,,if(t1=1) s2.addline(s1.ltrim 1)
ret


Messages In This Thread
Gets the content between two tags - by Davider - 10-28-2022, 03:38 AM
RE: Gets the content between two tags - by Kevin - 10-28-2022, 12:42 PM
RE: Gets the content between two tags - by Kevin - 10-28-2022, 07:49 PM
RE: Gets the content between two tags - by Kevin - 11-02-2022, 01:49 PM
RE: Gets the content between two tags - by Kevin - 11-03-2022, 04:19 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)