Posts: 1,154
Threads: 268
Joined: Jul 2022
06-27-2025, 11:03 PM
(This post was last modified: 06-27-2025, 11:04 PM by Davider.)
In the following code, using the replacerx function always takes effect, but using the findreplace function sometimes does not take effect.
I want to use the findreplace function because it has lower resource consumption.
Macro
Macro17
out
_s=
;Node,ReleaseDate,SMBIOSBIOSVersion
;
;DESKTOP-3URCFPT,20131216000000.000000+000,F1
_s.trim; _s.findreplace("[][]", "[]") ;;Sometimes does not take effect
;_s.replacerx("\r\n?\r\n" "[]") ;;Always takes effect
out _s
Posts: 1,154
Threads: 268
Joined: Jul 2022
06-28-2025, 07:37 AM
(This post was last modified: 06-28-2025, 07:47 AM by Davider.)
The following code always works. Is there a more concise way to write it?
The cause of issue #1 is that, in some cases, the line break is \r instead of \r\n.
_s=
;Node,ReleaseDate,SMBIOSBIOSVersion
;
;Node,ReleaseDate,SMBIOSBIOSVersion
;
;DESKTOP-3URCFPT,20131216000000.000000+000,F1
str b=
;
;
;
_s.trim; _s.findreplace(b, "[]")
The problem is solved, but there might be a better way.
_s.findreplace("[13][10][13][10]", "[]")
_s.findreplace("[13][13][10]", "[]")