Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Gets the content between two tags
#1
Hi,

I want to get all the content between the two tags (#if ... #endif)

I have the following powershell code, requests the QM code with the same effect

Thanks in advance for any advice and help
david

Powershell code:
Code:
Copy      Help
$s = @'
public static void Main(string[] args)
{
#if A
    part1
#endif

part
part

#if V
    part2
#endif

part
part

#if C
    part3
#endif
}
'@ -split [Environment]::NewLine

$between = $false
$ss= Switch -regex ($s)
{
    '#if.+|#endif' {
        $between = !$between
    }
    Default {
        If ($between)
        {
            $_
        }
    }
}
$ss


Macro Macro10
Code:
Copy      Help
out
_s=
;public static void Main(string[] args)
;{
;#if A
;,part1
;#endif
;
;part
;part
;
;#if V
;,part2
;#endif
;
;part
;part
;
;#if C
;,part3
;#endif
;}

;Todo: get all the content between the two tags (#if ... #endif)


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)