From: Ahmet Kilic Date: 2009-09-10T19:41:41+09:00 Subject: Re: regex: multiline Robert Klemme wrote: > 2009/9/10 7stud -- : >>> function TfrmExecMain.SetPrivilege(PrivilegeName: String; >>> for example; >> >> ENDOFSTRING >> >> md = str.match(/function.*?\):\s+(.*?;)/m) >> if md >>  puts md[1] >> end >> >> --output:-- >> Boolean; > > Note that you do not need the /m flag for this to match. This works > the same without it. The only difference that /m makes is whether > newlines are matched by .: > > irb(main):001:0> s = "a\nb\n" > => "a\nb\n" > irb(main):002:0> s[/.*/] > => "a" > irb(main):003:0> s[/.*/m] > => "a\nb\n" > > It does not make any difference for \s: > > irb(main):004:0> s[/\s+/] > => "\n" > irb(main):005:0> s[/\s+/m] > => "\n" > > I'll attach an extended example. > > Kind regards > > robert Thank you Robert, Wooow! your code is seen perfect. I want to ask one more question; my file contains many many functions, vars and begins like this, for example; ... function TfrmExecMain.GetApiErrorMessage(ApiErrCode :DWORD) :String; var Buf: array[0..511] of Char; MsgCnt :DWORD; begin ... function TfrmExecMain.SetPrivilege(PrivilegeName: String; Enable: Boolean): Boolean; var tpPrev, tp : TTokenPrivileges; token : THandle; dwRetLen : DWord; begin ... how can I do it with your code? should I write new regexp for each function? -- Posted via http://www.ruby-forum.com/.