【发布时间】:2014-12-30 15:49:23
【问题描述】:
有没有类似http://php.net/manual/en/function.preg-match-all.php的函数?
使用 GLib http://references.valadoc.org/#!api=glib-2.0/GLib.MatchInfo,我发现的只是:
public bool match_all_full (string str, ssize_t string_len = -1, int start_position = 0, RegexMatchFlags match_options = 0, out MatchInfo match_info = null) throws RegexError
Using the standard algorithm for regular expression matching only the longest match in the string is retrieved, it is not possible to obtain all the available matches.
它说不可能获得所有可用的匹配项。
我找不到任何有效的代码示例。感谢您的帮助。
注意:
目标是解析一个 plist 文件(我只需要 CFBundleIdentifier 和 CFBundleName 值)
<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">
<dict>
<key>CFBundleIdentifier</key>
<string>nodejs</string>
<key>CFBundleName</key>
<string>Node.js</string>
<key>DocSetPlatformFamily</key>
<string>nodejs</string>
<key>isDashDocset</key><true/><key>dashIndexFilePath</key><string>nodejs /api/documentation.html</string></dict>
</plist>
我有这些依赖项(ubuntu synapse 包):
Build-Depends: debhelper (>= 9),
dh-autoreconf,
gnome-common,
valac (>= 0.16.0),
libzeitgeist-2.0-dev (>= 0.9.14),
libdbus-glib-1-dev,
libgtk-3-dev (>= 3.0.0),
libglib2.0-dev (>= 2.28.0),
libgee-0.8-dev (>= 0.5.2),
libjson-glib-dev (>= 0.10.0),
libkeybinder-3.0-dev,
libnotify-dev,
librest-dev,
libappindicator3-dev (>= 0.0.7)
结果它给了我
** Message: main.vala:28: CFBundleIdentifier: cakephp
** Message: main.vala:28: CFBundleName: CakePHP
** Message: main.vala:28: DocSetPlatformFamily: cakephp
关于为什么不使用 xmllib 的问题? 该项目几乎没有依赖项,在 GNU 系统中(尽管我是新手),程序被打包假设只有某些依赖项,如果我不想使用我的插件,我想我必须只使用可用的依赖项或者我可能会破坏某些东西并阻止endsudoer的更新。
【问题讨论】:
-
为什么不使用 XML 库?
-
这应该使用 XML 库来完成,另请参阅:stackoverflow.com/questions/1732348/…