Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Regular expression modify
#1
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
 
Code:
Copy      Help
_s=
;s.fix(abc(h SCI.SCI_GETTEXTRANGE 0 &t))

_s.replacerx("abc\((?:(?>[^()]*)|\((?<Open>)|\)(?<-Open>))*(?(Open)(?!))\)")

Powershell code:
Code:
Copy      Help
$s='s.fix(abc(h SCI.SCI_GETTEXTRANGE 0 &t))';
$s -replace 'abc\((?:(?>[^()]*)|\((?<Open>)|\)(?<-Open>))*(?(Open)(?!))\)'
#2
I use another regular expression, which is not correct. The above expression is correct, but it is not supported in QM

Macro Macro22
Code:
Copy      Help
_s=
;s.fix(abc(h SCI.SCI_GETTEXTRANGE 0 &t))

_s.replacerx("abc\([^\)]*[^\(]*\)")
out _s
#3
this can help?

Function Function17
Code:
Copy      Help
_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
#4
Thanks for your help. 
 The result of the following example is wrong

Macro Macro21
Code:
Copy      Help
_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
 
Code:
Copy      Help
$s='xzc abc(s "(abc)"); dfg()';
$s -replace 'abc\((?:(?>[^()]*)|\((?<Open>)|\)(?<-Open>))*(?(Open)(?!))\)'
#5
Function Function17
Code:
Copy      Help
_s=
;xzc abc(s "(abc)"); dfg()
str pattern="abc\(s ''\(abc\)''\)"

_s.replacerx(pattern "")
out _s

;xzc ; dfg()
#6
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)")
#7
try this one
 
Code:
Copy      Help
_s.replacerx("(?<=[\w ]\()[^;\n]*(?=\))" "")
#8
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
#9
Code:
Copy      Help
$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
#10
https://www.google.com/search?q=C%23+Regex
#11
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


Forum Jump:


Users browsing this thread: 1 Guest(s)