怎么使用wxRegEx从文本里面获取一串wxString数组

这是wxWidgets论坛的中文版本。在这里,您可以用您的母语汉语讨论上面任一子论坛所涉及的所有关于wxWidgets的话题。欢迎大家参与到对有价值的帖子的中英互译工作中来!
winner4love
In need of some credit
In need of some credit
Posts: 5
Joined: Mon Dec 23, 2013 5:01 am

怎么使用wxRegEx从文本里面获取一串wxString数组

Postby winner4love » Sat Jan 04, 2014 3:29 pm

比如文本内容:
"data":{"001":"abc","002":"bcd","003":"cde","004":"def","005":"fgh"}
我要获得的是一个二维wxString数组,或两个wxArrayString对象:
001 abc
002 bcd
003 cde
004 def
005 fgh
彼此互相对应.
应该怎么应用wxRegEx达到这个效果呢?

kipade
Earned some good credits
Earned some good credits
Posts: 116
Joined: Fri Nov 11, 2011 2:45 am
Location: China

Re: 怎么使用wxRegEx从文本里面获取一串wxString数组

Postby kipade » Mon Jan 06, 2014 12:40 pm

取决于你的数据规则啊。
并不是所有的字符串操作都适用于正则表达式
Slackware GNU/Linux
wxWidgets-3.0.3

lfjking
Experienced Solver
Experienced Solver
Posts: 77
Joined: Mon Nov 14, 2016 1:35 pm

Re: 怎么使用wxRegEx从文本里面获取一串wxString数组

Postby lfjking » Mon May 08, 2017 11:36 am

winner4love wrote:比如文本内容:
"data":{"001":"abc","002":"bcd","003":"cde","004":"def","005":"fgh"}
我要获得的是一个二维wxString数组,或两个wxArrayString对象:
001 abc
002 bcd
003 cde
004 def
005 fgh
彼此互相对应.
应该怎么应用wxRegEx达到这个效果呢?



你应该用 JSON

kipade
Earned some good credits
Earned some good credits
Posts: 116
Joined: Fri Nov 11, 2011 2:45 am
Location: China

Re: 怎么使用wxRegEx从文本里面获取一串wxString数组

Postby kipade » Wed Aug 09, 2017 1:08 am

这个嘛,就正则表达示的应用示例就能解决你这个问题:
http://docs.wxwidgets.org/trunk/classwx ... 120331c2cb
Slackware GNU/Linux
wxWidgets-3.0.3


Return to “wxWidgets Development (Chinese)”

Who is online

Users browsing this forum: Baidu [Spider] and 2 guests