Page 1 of 1

Please help with RegExReplace

Posted: 04 Dec 2021, 21:51
by oldbrother
I want to remove 310 blocks in a DXF file. How can I do it with RegExReplace?

To remove:
310
a long string (length longer than 80)


Code: Select all

330
3773
100
AcDbXrecord
280
     1
310
28000000B40000006D0000000100080000000000A44C000000000000000000000001000000000000FFFFFF0000000000F
310
0000660000336600006666000099660000CC660000FF66000000990000339900006699000099990000CC990000FF990000
310
33006633330099333300CC333300FF33330000663300336633006666330099663300CC663300FF663300009933003
310
006600CC006600FF00660000336600333366006633660099336600CC336600FF33660000666600336666006666660
310
add
213
310
032423244
310
098322
To

Code: Select all

330
3773
100
AcDbXrecord
280
     1
310
add
213
310
032423244
310
098322

Re: Please help with RegExReplace

Posted: 04 Dec 2021, 22:01
by mikeyww

Code: Select all

Gosub, Init
MsgBox, 64, Result, % str := Trim(RegExReplace(str "`n", "m`a)310\R.{81,}\R"), "`n")

Init:
str =
(
330
3773
100
AcDbXrecord
280
     1
310
28000000B40000006D0000000100080000000000A44C000000000000000000000001000000000000FFFFFF0000000000F
310
0000660000336600006666000099660000CC660000FF66000000990000339900006699000099990000CC990000FF990000
310
33006633330099333300CC333300FF33330000663300336633006666330099663300CC663300FF663300009933003
310
006600CC006600FF00660000336600333366006633660099336600CC336600FF33660000666600336666006666660
310
add
213
310
032423244
310
098322
)
Return

Re: Please help with RegExReplace

Posted: 04 Dec 2021, 22:09
by oldbrother
Wow!

It works great! Thank you so much! :thumbup:

Re: Please help with RegExReplace

Posted: 05 Dec 2021, 08:35
by teadrinker
@mikeyww

Code: Select all

Gosub, Init
MsgBox, 64, Result, % str := Trim(RegExReplace(str "`n", "m`a)310\R.{81,}\R"), "`n")

Init:
str =
(
330
3773
100
AcDbXrecord
280
     1
666310
28000000B40000006D0000000100080000000000A44C000000000000000000000001000000000000FFFFFF0000000000F
666310
0000660000336600006666000099660000CC660000FF66000000990000339900006699000099990000CC990000FF990000
666310
33006633330099333300CC333300FF33330000663300336633006666330099663300CC663300FF663300009933003
666310
006600CC006600FF00660000336600333366006633660099336600CC336600FF33660000666600336666006666660
310
add
213
310
032423244
310
098322
)
Return

Re: Please help with RegExReplace

Posted: 05 Dec 2021, 08:48
by mikeyww
Thanks. Still works as stated, but if 310 should start and end the line, then ^ can be added before it in the regex.