Please help with RegExReplace

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
oldbrother
Posts: 273
Joined: 23 Oct 2013, 05:08

Please help with RegExReplace

04 Dec 2021, 21:51

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
User avatar
mikeyww
Posts: 26885
Joined: 09 Sep 2014, 18:38

Re: Please help with RegExReplace

04 Dec 2021, 22:01

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
User avatar
oldbrother
Posts: 273
Joined: 23 Oct 2013, 05:08

Re: Please help with RegExReplace

04 Dec 2021, 22:09

Wow!

It works great! Thank you so much! :thumbup:
teadrinker
Posts: 4326
Joined: 29 Mar 2015, 09:41
Contact:

Re: Please help with RegExReplace

05 Dec 2021, 08:35

@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
User avatar
mikeyww
Posts: 26885
Joined: 09 Sep 2014, 18:38

Re: Please help with RegExReplace

05 Dec 2021, 08:48

Thanks. Still works as stated, but if 310 should start and end the line, then ^ can be added before it in the regex.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Anput, Descolada, Joey5 and 322 guests