Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Unable to match all double byte characters
#32
@Kevin

How to exclude the strings for the comment line? I just want to find and replace the double byte string of non comment lines
I thought about it for a long time and didn't solve it Sad


Add the following code, the comment is removed, but there are the following problems
1. There are extra spaces or empty lines
2. There is no comment in the replacement result

_______________________
_s.replacerx("//.*" "")
e6=_s

Macro Macro3
Trigger A1     Help - how to add the trigger to the macro
Code:
Copy      Help
_s=
;class Program
;{
;,static void Main()
;,{
;,,//文件名 文字 中文
;,,Section section = new Section(document);
;,,document.Sections.Add(section);
;
;,,//This is the comment 中文
;,,Paragraph paragraph = new Paragraph(文件);
;,,section.Blocks.Add(paragraph);
;
;,,Run run = new Run(document, "文字");
;,,paragraph.Inlines.Add(run);
;
;,,document.Save("文件名.docx");
;,}
;}

str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 334 200 "Dialog" "4"
;3 Edit 0x54030080 0x200 8 160 95 13 ""
;4 Edit 0x54030080 0x200 120 160 95 13 ""
;5 Edit 0x54030080 0x200 232 160 95 13 ""
;6 Edit 0x54231044 0x200 8 8 318 146 ""
;1 Button 0x54030001 0x4 216 180 48 14 "OK"
;2 Button 0x54030000 0x4 272 180 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040B01 "*" "" "" ""

str controls = "3 4 5 6"
str e3 e4 e5 e6

_s.replacerx("//.*" "")

e6=_s

ARRAY(str) a
str pattern="[\x80-\xff]+" ;;Match all double byte characters
if(findrx(_s pattern 0 4 a)<0) out "does not match"; ret
for int'i 0 a.len
,sel i
,,case 0
,,e3 = a[0 i]
,,case 1
,,e4 = a[0 i]
,,case 2
,,e5 = a[0 i]

if(!ShowDialog(dd 0 &controls)) ret

int ci
for i 0 a.len
,sel i
,,case 0
,,ci=_s.findreplace(a[0 i] F"{e3}" 4)
,,case 1
,,ci=_s.findreplace(a[0 i] F"{e4}" 4 "" ci+e3.len)
,,case 2
,,ci=_s.findreplace(a[0 i] F"{e5}" 4 "" ci+e4.len)

mes _s


Messages In This Thread
RE: Unable to match all double byte characters - by macman - 01-22-2021, 11:20 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)