<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Linux Forum &mdash; Regex в С/С++]]></title>
	<link rel="self" href="https://linuxforum.ru/extern.php?action=feed&amp;tid=10025&amp;type=atom" />
	<updated>2011-01-18T13:42:05Z</updated>
	<generator>PunBB</generator>
	<id>https://linuxforum.ru/viewtopic.php?id=10025</id>
		<entry>
			<title type="html"><![CDATA[Re: Regex в С/С++]]></title>
			<link rel="alternate" href="https://linuxforum.ru/viewtopic.php?pid=133695#p133695" />
			<content type="html"><![CDATA[<div class="codebox"><pre><code>regexec (const regex_t *restrict preg, const char *restrict string, size_t nmatch, regmatch_t pmatch [restrict], int eflags);</code></pre></div><p>В pmatch и nmatch что именно попадает?<br />Я правильно понял:<br />если мы задаём регулярку не ограниченную ^ и $ то в массив попадут все &quot;куски&quot; совпавшие?</p>]]></content>
			<author>
				<name><![CDATA[lamazavr]]></name>
				<uri>https://linuxforum.ru/profile.php?id=14229</uri>
			</author>
			<updated>2011-01-18T13:42:05Z</updated>
			<id>https://linuxforum.ru/viewtopic.php?pid=133695#p133695</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Regex в С/С++]]></title>
			<link rel="alternate" href="https://linuxforum.ru/viewtopic.php?pid=132493#p132493" />
			<content type="html"><![CDATA[<div class="codebox"><pre><code>#include &lt;locale.h&gt;
#include &lt;stdio.h&gt;
#include &lt;string.h&gt;
#include &lt;unistd.h&gt;
#include &lt;sys/types.h&gt;
#include &lt;regex.h&gt;

#define ERRBUF_SIZE 1024
#define NMATCH 10

void error(int err_code, regex_t *rs)1
{
        char errbuf[ERRBUF_SIZE];
        if(!err_code)   return;
        regerror(err_code, rs, errbuf, ERRBUF_SIZE);
        fprintf(stderr, &quot;regex error: %s\n&quot;, errbuf);
        regfree(rs);
        _exit(err_code);
}

int main(void)
{
        const char str[] = &quot;тестов\xD1\xD1ая строчка. ABCDEFG&quot;;2
        const char regex[] = &quot;.*&quot;;3
        regex_t rs;
        regmatch_t pmatch[NMATCH];
        char *lc = setlocale(LC_ALL, &quot;ru_RU.UTF-8&quot;);4
        if(!lc)    return 77;
        printf(&quot;test string: `%s&#039; (%s)\n&quot;, str, lc);
        int err = regcomp(&amp;rs, regex, REG_EXTENDED);
        error(err, &amp;rs);
        const char *ps = str;
        while(*ps)5
        {
                err = regexec(&amp;rs, ps, NMATCH, pmatch, 0);
                error(err, &amp;rs);
                int j;
                const char *ps2 = NULL;
                for(j = 0; j &lt; NMATCH; j++)
                {
                        if(pmatch[j].rm_so &lt; 0)
                                continue;
                        printf(&quot;Совпадение %d: %d...%d\t`&quot;, j, pmatch[j].rm_so, pmatch[j].rm_eo);
                        int i;
                        for(i = pmatch[j].rm_so; i &lt; pmatch[j].rm_eo; i++)
                                printf(&quot;%c&quot;, ps[i]);
                        printf(&quot;&#039;\n&quot;);
                        if(!ps2)
                                ps2 = ps + i;6
                }
                ps = ps2;
                if(!ps)    break;7
                printf(&quot;остаток: `%s&#039;\n&quot;, ps);
        }
        regfree(&amp;rs);
        return 0;
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[drBatty]]></name>
				<uri>https://linuxforum.ru/profile.php?id=86</uri>
			</author>
			<updated>2011-01-15T08:42:49Z</updated>
			<id>https://linuxforum.ru/viewtopic.php?pid=132493#p132493</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Regex в С/С++]]></title>
			<link rel="alternate" href="https://linuxforum.ru/viewtopic.php?pid=132491#p132491" />
			<content type="html"><![CDATA[<p>вот вам пример: <a href="http://drbatty.ru/sed/ch02s04.html#bugs_utf">http://drbatty.ru/sed/ch02s04.html#bugs_utf</a><br />что там непонятно?</p>]]></content>
			<author>
				<name><![CDATA[drBatty]]></name>
				<uri>https://linuxforum.ru/profile.php?id=86</uri>
			</author>
			<updated>2011-01-15T08:42:13Z</updated>
			<id>https://linuxforum.ru/viewtopic.php?pid=132491#p132491</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Regex в С/С++]]></title>
			<link rel="alternate" href="https://linuxforum.ru/viewtopic.php?pid=132263#p132263" />
			<content type="html"><![CDATA[<p>libpcre + маны к ней.</p>]]></content>
			<author>
				<name><![CDATA[RasenHerz]]></name>
				<uri>https://linuxforum.ru/profile.php?id=14409</uri>
			</author>
			<updated>2011-01-14T14:37:28Z</updated>
			<id>https://linuxforum.ru/viewtopic.php?pid=132263#p132263</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Regex в С/С++]]></title>
			<link rel="alternate" href="https://linuxforum.ru/viewtopic.php?pid=132177#p132177" />
			<content type="html"><![CDATA[<p>тру не тру, но по сути везде используется одна и таже система регэкспов (стандарт POSIX), различия минимальны, так что ковыряйте boost и Фридл в помощь <img src="https://linuxforum.ru/img/smilies/bx.gif" alt="bx" />))</p>]]></content>
			<author>
				<name><![CDATA[Root_Lamer]]></name>
				<uri>https://linuxforum.ru/profile.php?id=5498</uri>
			</author>
			<updated>2011-01-14T11:21:02Z</updated>
			<id>https://linuxforum.ru/viewtopic.php?pid=132177#p132177</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Regex в С/С++]]></title>
			<link rel="alternate" href="https://linuxforum.ru/viewtopic.php?pid=132165#p132165" />
			<content type="html"><![CDATA[<p>это всё хорошо) но нужно в С/С++ <br />.net не тру&nbsp; :rolleyes:</p>]]></content>
			<author>
				<name><![CDATA[lamazavr]]></name>
				<uri>https://linuxforum.ru/profile.php?id=14229</uri>
			</author>
			<updated>2011-01-14T10:51:44Z</updated>
			<id>https://linuxforum.ru/viewtopic.php?pid=132165#p132165</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Regex в С/С++]]></title>
			<link rel="alternate" href="https://linuxforum.ru/viewtopic.php?pid=132141#p132141" />
			<content type="html"><![CDATA[<p>Справочник по регэкспам Джефри Фридла<br /><a href="http://www.filesonic.com/file/235888/reg_vyr.rar">http://www.filesonic.com/file/235888/reg_vyr.rar</a></p>]]></content>
			<author>
				<name><![CDATA[Root_Lamer]]></name>
				<uri>https://linuxforum.ru/profile.php?id=5498</uri>
			</author>
			<updated>2011-01-14T10:04:58Z</updated>
			<id>https://linuxforum.ru/viewtopic.php?pid=132141#p132141</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Regex в С/С++]]></title>
			<link rel="alternate" href="https://linuxforum.ru/viewtopic.php?pid=132132#p132132" />
			<content type="html"><![CDATA[<p>Народ подскажите книжонку с подробным описанием функций&nbsp; smile ато замучался искать..</p>]]></content>
			<author>
				<name><![CDATA[lamazavr]]></name>
				<uri>https://linuxforum.ru/profile.php?id=14229</uri>
			</author>
			<updated>2011-01-14T09:39:00Z</updated>
			<id>https://linuxforum.ru/viewtopic.php?pid=132132#p132132</id>
		</entry>
</feed>
