Posts: 1,031
Threads: 246
Joined: Jul 2022
03-12-2023, 01:40 AM
(This post was last modified: 03-12-2023, 03:21 AM by Davider.)
Hi,
I need to delete the following red words. The following regular expression can be executed successfully in powershell, but it is not supported in QM. How do I modify it
s.fix(
abc(h SCI.SCI_GETTEXTRANGE 0 &t))
https://learn.microsoft.com/en-us/dotnet...definition
Macro
Macro22
_s=
;s.fix(abc(h SCI.SCI_GETTEXTRANGE 0 &t))
_s.replacerx("abc\((?:(?>[^()]*)|\((?<Open>)|\)(?<-Open>))*(?(Open)(?!))\)")
Powershell code:
$s='s.fix(abc(h SCI.SCI_GETTEXTRANGE 0 &t))';
$s -replace 'abc\((?:(?>[^()]*)|\((?<Open>)|\)(?<-Open>))*(?(Open)(?!))\)'
Posts: 1,031
Threads: 246
Joined: Jul 2022
I use another regular expression, which is not correct. The above expression is correct, but it is not supported in QM
Macro
Macro22
_s=
;s.fix(abc(h SCI.SCI_GETTEXTRANGE 0 &t))
_s.replacerx("abc\([^\)]*[^\(]*\)")
out _s
Posts: 229
Threads: 22
Joined: Sep 2007
03-12-2023, 05:51 PM
(This post was last modified: 03-12-2023, 05:53 PM by redbull2k.)
this can help?
Function
Function17
_s=
;s.fix(abc(h SCI.SCI_GETTEXTRANGE 0 &t))
str pattern="abc[-\(].*?[-\)]"
_s.replacerx(pattern)
out _s
;str a
;if(findrx(_s pattern 0 4 a))
,;out a
Posts: 1,031
Threads: 246
Joined: Jul 2022
03-12-2023, 09:27 PM
(This post was last modified: 03-12-2023, 09:36 PM by Davider.)
Thanks for your help.
The result of the following example is wrong
Macro
Macro21
_s=
;xzc abc(s "(abc)"); dfg()
str pattern="abc[-\(].*?[-\)]"
_s.replacerx(pattern)
out _s
Using the following powershell code, the result is always correct, But the execution speed is too slow
$s='xzc abc(s "(abc)"); dfg()';
$s -replace 'abc\((?:(?>[^()]*)|\((?<Open>)|\)(?<-Open>))*(?(Open)(?!))\)'
Posts: 229
Threads: 22
Joined: Sep 2007
Function
Function17
_s=
;xzc abc(s "(abc)"); dfg()
str pattern="abc\(s ''\(abc\)''\)"
_s.replacerx(pattern "")
out _s
;xzc ; dfg()
Posts: 1,031
Threads: 246
Joined: Jul 2022
Sorry, my description is not clear enough. In the actual case, I don't know the content of the following red words
abc(s "(abc)")
Posts: 1,336
Threads: 61
Joined: Jul 2006
try this one
_s.replacerx("(?<=[\w ]\()[^;\n]*(?=\))" "")
Posts: 1,031
Threads: 246
Joined: Jul 2022
03-13-2023, 06:13 AM
(This post was last modified: 03-13-2023, 06:15 AM by Davider.)
Sorry, I don't know how to express.....
I want to delete the specified word and the brackets after it
For the following example: abc and the brackets after it
The result I expect is:
s1:
xzc ; dfg()
s2:
s.fix()
-------------------------------------------------
out
str s1=
xzc abc(s "(abc)"); dfg()
str s2=
s.fix(abc(h SCI.SCI_GETTEXTRANGE 0 &t))
str p="(?<=[\w ]\()[^;\n]*(?=\))"
s1.replacerx(p)
out s1
s2.replacerx(p)
out s2
Posts: 1,031
Threads: 246
Joined: Jul 2022
04-16-2023, 06:30 AM
(This post was last modified: 04-16-2023, 06:31 AM by Davider.)
$s='s.fix(abc(h SCI.SCI_GETTEXTRANGE 0 &t))';
$s -replace 'abc\((?:(?>[^()]*)|\((?<Open>)|\)(?<-Open>))*(?(Open)(?!))\)'
in LA, What is the equivalent code for powershell regular expressions ?
I tried, but PCRE2 does not support the above regular expressions
Posts: 12,073
Threads: 140
Joined: Dec 2002
Posts: 1,031
Threads: 246
Joined: Jul 2022
Thank you for reminding me that
LA is very powerful. It supports the built-in C # regular engine and also supports the PCRE2 regular engine