Re: [Vala] vala regex question.



On Fri, 2010-11-19 at 22:41 +0900, san hoi wrote:
// hello.cs
using System;
using System.Text.RegularExpressions;

class HelloWorld {
  public static void Main() {
      System.IO.StreamReader sr = new
System.IO.StreamReader(@"/opt/the-board/share/vala-0.12/vapi/cairo.vapi");
      string gscode = sr.ReadToEnd();
      sr.Close();
      Console.WriteLine(gscode);

      Regex r = new Regex(@"\{.*?\}", RegexOptions.Singleline);
      System.Text.RegularExpressions.MatchCollection mc = r.Matches(gscode);

      foreach (System.Text.RegularExpressions.Match m in mc)
      {
          Console.WriteLine(m.Value);
      }
  }
}

I think that python's dir method is usable. so

$vapidir "cairo-1.0/Matrix" => show matrix detail : pick up from
dictionary {..., "Matrix": matrix_struct_difinition, ... }

maybe usable too...but I don't know vala's multi-line regex matching.
Above code is csharp case. Is enable that vala's case?

I'm not too familiar with .NET, so I can't tell you exactly what would
correspond to the above code. Vala uses GLib's regular expressions
(GRegex, bound in glib-2.0.vapi as GLib.Regex). Documentation of the
syntax is available at [1], C API at [2]. I think you'll be especially
interested in the GRegexCompileFlags documentation.

You may also be interested in the experimental regular expression
syntax. There is a brief explanation at [3].


[1] http://library.gnome.org/devel/glib/stable/glib-regex-syntax.html
[2]
http://library.gnome.org/devel/glib/stable/glib-Perl-compatible-regular-expressions.html
[3] http://live.gnome.org/Vala/Tutorial#Regular_Expression_Literals




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]