开发者

Finding multiple regex hits using approximate matching via the tre library

Using C, I'm trying to find the location and number of matches of a substring within another parent string. Because I also need to include approximate (hamming distance) matches, I'm using the tre library found here: http://la开发者_JS百科urikari.net/tre/.

I'm having trouble understanding some of the documentation on the site, likely because I'm not too familiar with regex lingo. According to the tre documentation, I can get more specific information about 'submatches'. Are these the matches I'm looking for?

Thanks!


To answer a part of your question about sub-matches: take the example string:

"noise aaa123bbb456ccc more noise"

and the regex:

aaa(.*?)bbb(.*?)ccc

then the entire match holds aaa123bbb456ccc which has two sub-matches in it: 123 and 456. These sub-matches are also called groups (the strings that are matched by the part of the regex between parenthesis).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜