#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <assert.h>
#include <pcre.h>
#include <string.h>


#define OVECCOUNT 30 /* should be a multiple of 3 */
#define EBUFLEN 128
#define BUFLEN 1024

int main_adfs()
{
    pcre *reCM,*reUN,*reTC,*reCDMA;
    const char *error;
    int erroffset;
    int ovector[OVECCOUNT];
    int rcCM,rcUN,rcTC,rcCDMA,i;

    /*
            yidong:134.135.136.137.138.139.150.151.152.157.158.159.187.188,147
            liandong:130.131.132.155.156.185.186
            dianxin:133.153.180.189
            CDMA :133,153
         */
    char src[22];
    char pattern_CM[] = "^1(3[4-9]|5[012789]|8[78])\\d{8}$";
    char pattern_UN[] = "^1(3[0-2]|5[56]|8[56])\\d{8}$";
    char pattern_TC[] = "^18[09]\\d{8}$";
    char pattern_CDMA[] = "^1[35]3\\d{8}$";

    printf("please input your telephone number \n");
    scanf("%s",src);
    printf("String : %s\n",src);
    printf("Pattern_CM: \"%s\"\n",pattern_CM);
    printf("Pattern_UN: \"%s\"\n",pattern_UN);
    printf("Pattern_TC: \"%s\"\n",pattern_TC);
    printf("Pattern_CDMA: \"%s\"\n",pattern_CDMA);

    reCM = pcre_compile(pattern_CM,&error,&erroffset,NULL);
    reUN = pcre_compile(pattern_UN,NULL);
    reTC = pcre_compile(pattern_TC,NULL);
    reCDMA = pcre_compile(pattern_CDMA,NULL);

    if (reCM==NULL && reUN==NULL && reTC==NULL && reCDMA==NULL) {
        printf("PCRE compilation telephone Failed at offset %d: %s\n",erroffset,error);
        return 1;
    }

    rcCM = pcre_exec(reCM,NULL,src,strlen(src),ovector,OVECCOUNT);
    rcUN = pcre_exec(reUN,OVECCOUNT);
    rcTC = pcre_exec(reTC,OVECCOUNT);
    rcCDMA = pcre_exec(reCDMA,OVECCOUNT);

    if (rcCM<0 && rcUN<0 && rcTC<0 && rcCDMA<0) {
        if (rcCM==PCRE_ERROR_NOMATCH && rcUN==PCRE_ERROR_NOMATCH &&
                rcTC==PCRE_ERROR_NOMATCH && rcTC==PCRE_ERROR_NOMATCH) {
            printf("Sorry,no match ...\n");
        }
        else {
            printf("Matching error %d\n",rcCM);
            printf("Matching error %d\n",rcUN);
            printf("Matching error %d\n",rcTC);
            printf("Matching error %d\n",rcCDMA);
        }
        free(reCM);
        free(reUN);
        free(reTC);
        free(reCDMA);
        return 1;
    }
    printf("\nOK,has matched ...\n\n");
    if (rcCM > 0) {
        printf("Pattern_CM: \"%s\"\n",pattern_CM);
        printf("String : %s\n",src);
    }
    if (rcUN > 0) {
        printf("Pattern_UN: \"%s\"\n",pattern_UN);
        printf("String : %s\n",src);
    }
    if (rcTC > 0) {
        printf("Pattern_TC: \"%s\"\n",pattern_TC);
        printf("String : %s\n",src);
    }
    if (rcCDMA > 0) {
        printf("Pattern_CDMA: \"%s\"\n",pattern_CDMA);
        printf("String : %s\n",src);
    }
    free(reCM);
    free(reUN);
    free(reTC);
    free(reCDMA);
    return 0;
}

#include <stdio.h>
#include <string.h>
#include <pcre.h>
#define OVECCOUNT 30 /* should be a multiple of 3 */
#define EBUFLEN 128
#define BUFLEN 1024

int main(int argc,char **argv)
{


    pcre *re;
    const char *error;
    int  erroffset;
    int  ovector[OVECCOUNT];
    int  rc,i;

    char src[] = "123.123.123.123:80|1.1.1.1:88";
    char pattern[] = "(\\d*.\\d*.\\d*.\\d*):(\\d*)";

    printf("String : %s\n",src);
    printf("Pattern: \"%s\"\n",pattern);


    re = pcre_compile(pattern,NULL);
    if (re == NULL) {
        printf("PCRE compilation Failed at offset %d: %s\n",error);
        return 1;
    }

    char *p = src;
    while ( ( rc = pcre_exec(re,p,strlen(p),OVECCOUNT)) != PCRE_ERROR_NOMATCH )
    {
        printf("\nOK,has matched ...\n\n");

        for (i = 0; i < rc; i++)
        {
            char *substring_start = p + ovector[2*i];
            int substring_length = ovector[2*i+1] - ovector[2*i];
            char matched[1024];
            memset( matched,1024 );
            strncpy( matched,substring_start,substring_length );

            printf( "match:%s\n",matched );
        }

        p += ovector[1];
        if ( !p )
        {
            break;
        }
    }
    pcre_free(re);

    return 0;
}

/*************************************************
*           PCRE DEMONSTRATION PROGRAM           *
*************************************************/

/* This is a demonstration program to illustrate the most straightforward ways
of calling the PCRE regular expression library from a C program. See the
pcresample documentation for a short discussion ("man pcresample" if you have
the PCRE man pages installed).

In Unix-like environments,if PCRE is installed in your standard system
libraries,you should be able to compile this program using this command:

gcc -Wall pcredemo.c -lpcre -o pcredemo

If PCRE is not installed in a standard place,it is likely to be installed with
support for the pkg-config mechanism. If you have pkg-config,you can compile
this program using this command:

gcc -Wall pcredemo.c `pkg-config --cflags --libs libpcre` -o pcredemo

If you do not have pkg-config,you may have to use this:

gcc -Wall pcredemo.c -I/usr/local/include -L/usr/local/lib \
  -R/usr/local/lib -lpcre -o pcredemo

Replace "/usr/local/include" and "/usr/local/lib" with wherever the include and
library files for PCRE are installed on your system. Only some operating
systems (e.g. Solaris) use the -R option.

Building under Windows:

If you want to statically link this program against a non-dll .a file,you must
define PCRE_STATIC before including pcre.h,otherwise the pcre_malloc() and
pcre_free() exported functions will be declared __declspec(dllimport),with
unwanted results. So in this environment,uncomment the following line. */

/* #define PCRE_STATIC */

#include <stdio.h>
#include <string.h>
#include <pcre.h>

#define OVECCOUNT 30    /* should be a multiple of 3 */


//http://tool.chinaz.com/regex/
int main2(int argc,char **argv)
{
    pcre *re;
    const char *error;
    char *pattern;
    char *subject;
    unsigned char *name_table;
    unsigned int option_bits;
    int erroffset;
    int find_all;
    int crlf_is_newline;
    int namecount;
    int name_entry_size;
    int ovector[OVECCOUNT];
    int subject_length;
    int rc,i;
    int utf8;


    /**************************************************************************
* First,sort out the command line. There is only one possible option at  *
* the moment,"-g" to request repeated matching to find all occurrences,*
* like Perl's /g option. We set the variable find_all to a non-zero value *
* if the -g option is present. Apart from that,there must be exactly two *
* arguments.                                                              *
**************************************************************************/

    find_all = 0;
    for (i = 1; i < argc; i++)
    {
        if (strcmp(argv[i],"-g") == 0) find_all = 1;
        else break;
    }

    /* After the options,we require exactly two arguments,which are the pattern,and the subject string. */

    if (argc - i != 2)
    {
        printf("Two arguments required: a regex and a subject string\n");
        return 1;
    }

    pattern = argv[i];
    subject = argv[i+1];
    subject_length = (int)strlen(subject);


    /*************************************************************************
* Now we are going to compile the regular expression pattern,and handle *
* and errors that are detected.                                          *
*************************************************************************/

    re = pcre_compile(
                pattern,/* the pattern */
                0,/* default options */
                &error,/* for error message */
                &erroffset,/* for error offset */
                NULL);                /* use default character tables */

    /* Compilation Failed: print the error message and exit */

    if (re == NULL)
    {
        printf("PCRE compilation Failed at offset %d: %s\n",error);
        return 1;
    }


    /*************************************************************************
* If the compilation succeeded,we call PCRE again,in order to do a     *
* pattern match against the subject string. This does just ONE match. If *
* further matching is needed,it will be done below.                     *
*************************************************************************/

    rc = pcre_exec(
                re,/* the compiled pattern */
                NULL,/* no extra data - we didn't study the pattern */
                subject,/* the subject string */
                subject_length,/* the length of the subject */
                0,/* start at offset 0 in the subject */
                0,/* default options */
                ovector,/* output vector for substring information */
                OVECCOUNT);           /* number of elements in the output vector */

    /* Matching Failed: handle error cases */

    if (rc < 0)
    {
        switch(rc)
        {
        case PCRE_ERROR_NOMATCH: printf("No match\n"); break;
            /*
    Handle other special cases if you like
    */
        default: printf("Matching error %d\n",rc); break;
        }
        pcre_free(re);     /* Release memory used for the compiled pattern */
        return 1;
    }

    /* Match succeded */

    printf("\nMatch succeeded at offset %d\n",ovector[0]);


    /*************************************************************************
* We have found the first match within the subject string. If the output *
* vector wasn't big enough,say so. Then output any substrings that were *
* captured.                                                              *
*************************************************************************/

    /* The output vector wasn't big enough */

    if (rc == 0)
    {
        rc = OVECCOUNT/3;
        printf("ovector only has room for %d captured substrings\n",rc - 1);
    }

    /* Show substrings stored in the output vector by number. ObvIoUsly,in a real
application you might want to do things other than print them. */

    for (i = 0; i < rc; i++)
    {
        char *substring_start = subject + ovector[2*i];
        int substring_length = ovector[2*i+1] - ovector[2*i];
        printf("%2d: %.*s\n",i,substring_length,substring_start);
    }


    /**************************************************************************
* That concludes the basic part of this demonstration program. We have    *
* compiled a pattern,and performed a single match. The code that follows *
* shows first how to access named substrings,and then how to code for    *
* repeated matches on the same subject.                                   *
**************************************************************************/

    /* See if there are any named substrings,and if so,show them by name. First
we have to extract the count of named parentheses from the pattern. */

    (void)pcre_fullinfo(
                re,/* no extra data - we didn't study the pattern */
                PCRE_INFO_NAMECOUNT,/* number of named substrings */
                &namecount);          /* where to put the answer */

    if (namecount <= 0) printf("No named substrings\n"); else
    {
        unsigned char *tabptr;
        printf("Named substrings\n");

        /* Before we can access the substrings,we must extract the table for
  translating names to numbers,and the size of each entry in the table. */

        (void)pcre_fullinfo(
                    re,/* the compiled pattern */
                    NULL,/* no extra data - we didn't study the pattern */
                    PCRE_INFO_NAMetaBLE,/* address of the table */
                    &name_table);             /* where to put the answer */

        (void)pcre_fullinfo(
                    re,/* no extra data - we didn't study the pattern */
                    PCRE_INFO_NAMEENTRYSIZE,/* size of each entry in the table */
                    &name_entry_size);        /* where to put the answer */

        /* Now we can scan the table and,for each entry,print the number,the name,and the substring itself. */

        tabptr = name_table;
        for (i = 0; i < namecount; i++)
        {
            int n = (tabptr[0] << 8) | tabptr[1];
            printf("(%d) %*s: %.*s\n",n,name_entry_size - 3,tabptr + 2,ovector[2*n+1] - ovector[2*n],subject + ovector[2*n]);
            tabptr += name_entry_size;
        }
    }


    /*************************************************************************
* If the "-g" option was given on the command line,we want to continue  *
* to search for additional matches in the subject string,in a similar   *
* way to the /g option in Perl. This turns out to be trickier than you   *
* might think because of the possibility of matching an empty string.    *
* What happens is as follows:                                            *
*                                                                        *
* If the prevIoUs match was NOT for an empty string,we can just start   *
* the next match at the end of the prevIoUs one.                         *
*                                                                        *
* If the prevIoUs match WAS for an empty string,we can't do that,as it *
* would lead to an infinite loop. Instead,a special call of pcre_exec() *
* is made with the PCRE_NOTEMPTY_ATSTART and PCRE_ANCHORED flags set.    *
* The first of these tells PCRE that an empty string at the start of the *
* subject is not a valid match; other possibilities must be tried. The   *
* second flag restricts PCRE to one match attempt at the initial string  *
* position. If this match succeeds,an alternative to the empty string   *
* match has been found,and we can print it and proceed round the loop,*
* advancing by the length of whatever was found. If this match does not  *
* succeed,we still stay in the loop,advancing by just one character.   *
* In UTF-8 mode,which can be set by (*UTF8) in the pattern,this may be *
* more than one byte.                                                    *
*                                                                        *
* However,there is a complication concerned with newlines. When the     *
* newline convention is such that CRLF is a valid newline,we want must  *
* advance by two characters rather than one. The newline convention can  *
* be set in the regex by (*CR),etc.; if not,we must find the default.  *
*************************************************************************/

    if (!find_all)     /* Check for -g */
    {
        pcre_free(re);   /* Release the memory used for the compiled pattern */
        return 0;        /* Finish unless -g was given */
    }

    /* Before running the loop,check for UTF-8 and whether CRLF is a valid newline
sequence. First,find the options with which the regex was compiled; extract
the UTF-8 state,and mask off all but the newline options. */

    (void)pcre_fullinfo(re,PCRE_INFO_OPTIONS,&option_bits);
    utf8 = option_bits & PCRE_UTF8;
    option_bits &= PCRE_NEWLINE_CR|PCRE_NEWLINE_LF|PCRE_NEWLINE_CRLF|
            PCRE_NEWLINE_ANY|PCRE_NEWLINE_ANYCRLF;

    /* If no newline options were set,find the default newline convention from the
build configuration. */

    if (option_bits == 0)
    {
        int d;
        (void)pcre_config(PCRE_CONfig_NEWLINE,&d);
        /* Note that these values are always the ASCII ones,even in
  EBCDIC environments. CR = 13,NL = 10. */
        option_bits = (d == 13)? PCRE_NEWLINE_CR :
                                 (d == 10)? PCRE_NEWLINE_LF :
                                            (d == (13<<8 | 10))? PCRE_NEWLINE_CRLF :
                                                                 (d == -2)? PCRE_NEWLINE_ANYCRLF :
                                                                            (d == -1)? PCRE_NEWLINE_ANY : 0;
    }

    /* See if CRLF is a valid newline sequence. */

    crlf_is_newline =
            option_bits == PCRE_NEWLINE_ANY ||
            option_bits == PCRE_NEWLINE_CRLF ||
            option_bits == PCRE_NEWLINE_ANYCRLF;

    /* Loop for second and subsequent matches */

    for (;;)
    {
        int options = 0;                 /* normally no options */
        int start_offset = ovector[1];   /* Start at end of prevIoUs match */

        /* If the prevIoUs match was for an empty string,we are finished if we are
  at the end of the subject. Otherwise,arrange to run another match at the
  same point to see if a non-empty match can be found. */

        if (ovector[0] == ovector[1])
        {
            if (ovector[0] == subject_length) break;
            options = PCRE_NOTEMPTY_ATSTART | PCRE_ANCHORED;
        }

        /* Run the next matching operation */

        rc = pcre_exec(
                    re,/* no extra data - we didn't study the pattern */
                    subject,/* the subject string */
                    subject_length,/* the length of the subject */
                    start_offset,/* starting offset in the subject */
                    options,/* options */
                    ovector,/* output vector for substring information */
                    OVECCOUNT);           /* number of elements in the output vector */

        /* This time,a result of NOMATCH isn't an error. If the value in "options"
  is zero,it just means we have found all possible matches,so the loop ends.
  Otherwise,it means we have Failed to find a non-empty-string match at a
  point where there was a prevIoUs empty-string match. In this case,we do what
  Perl does: advance the matching position by one character,and continue. We
  do this by setting the "end of prevIoUs match" offset,because that is picked
  up at the top of the loop as the point at which to start again.

  There are two complications: (a) When CRLF is a valid newline sequence,and
  the current position is just before it,advance by an extra byte. (b)
  Otherwise we must ensure that we skip an entire UTF-8 character if we are in
  UTF-8 mode. */

        if (rc == PCRE_ERROR_NOMATCH)
        {
            if (options == 0) break;                    /* All matches found */
            ovector[1] = start_offset + 1;              /* Advance one byte */
            if (crlf_is_newline &&                      /* If CRLF is newline & */
                    start_offset < subject_length - 1 &&    /* we are at CRLF,*/
                    subject[start_offset] == '\r' &&
                    subject[start_offset + 1] == '\n')
                ovector[1] += 1;                          /* Advance by one more. */
            else if (utf8)                              /* Otherwise,ensure we */
            {                                         /* advance a whole UTF-8 */
                while (ovector[1] < subject_length)       /* character. */
                {
                    if ((subject[ovector[1]] & 0xc0) != 0x80) break;
                    ovector[1] += 1;
                }
            }
            continue;    /* Go round the loop again */
        }

        /* Other matching errors are not recoverable. */

        if (rc < 0)
        {
            printf("Matching error %d\n",rc);
            pcre_free(re);    /* Release memory used for the compiled pattern */
            return 1;
        }

        /* Match succeded */

        printf("\nMatch succeeded again at offset %d\n",ovector[0]);

        /* The match succeeded,but the output vector wasn't big enough. */

        if (rc == 0)
        {
            rc = OVECCOUNT/3;
            printf("ovector only has room for %d captured substrings\n",rc - 1);
        }

        /* As before,show substrings stored in the output vector by number,and then
  also any named substrings. */

        for (i = 0; i < rc; i++)
        {
            char *substring_start = subject + ovector[2*i];
            int substring_length = ovector[2*i+1] - ovector[2*i];
            printf("%2d: %.*s\n",substring_start);
        }

        if (namecount <= 0) printf("No named substrings\n"); else
        {
            unsigned char *tabptr = name_table;
            printf("Named substrings\n");
            for (i = 0; i < namecount; i++)
            {
                int n = (tabptr[0] << 8) | tabptr[1];
                printf("(%d) %*s: %.*s\n",subject + ovector[2*n]);
                tabptr += name_entry_size;
            }
        }
    }      /* End of loop to find second and subsequent matches */

    printf("\n");
    pcre_free(re);       /* Release memory used for the compiled pattern */
    return 0;
}

/* End of pcredemo.c */

#include <string.h>
#include <stdio.h>
#include <pcre.h>

int main_split(int argc,char **argv)
{
    pcre *re;
    const char *error;
    int errorOffset,i = 0;
    /**
     * pcre_exec匹配的结果
     * ovector的结构为
     * {匹配结果1的起始位置,匹配结果1的结束位置,匹配结果2的起始位置,...匹配结果N的结束位置}
     */
    int oveccount = 2;
    int ovector[2];

    /**
     * rc是pcre_exec匹配到的结果数量
     */
    int rc;
    /**
     * pcre_exec执行的偏移量
     * 从匹配到的结果的结束位置开始下一次匹配
     */
    int exec_offset = 0;


    const char *captured_string;
    char *subject = "1t  2t  3t  4t    5t  6t7t8t9t0ta tbtct f1024 t 96t";
    char *pattern = "[^ ]+[^ ]";

    re = pcre_compile( pattern,PCRE_CASELESS,&errorOffset,NULL );

    if ( re == NULL ) {
        printf("compilation Failed at offset%d: %s\n",errorOffset,error);
        return 0;
    }

    do {
        // exec_offset偏移量 默认从1开始,然后循环的时候从匹配到的结果开始
        rc = pcre_exec( re,subject,strlen(subject),exec_offset,oveccount );
        if ( rc > 0 ) {
            // 获取到匹配的结果
            pcre_get_substring( subject,rc,&captured_string );
            printf("captured string : [%s]\n",captured_string);
            // 设置偏移量
            exec_offset = ovector[1];
            i++;
        }
    } while ( rc > 0 );

    printf("match %d\n",i);

    return 0;
}

#include <stdio.h>
#include <string.h>
#include <pcre.h>
#define OVECCOUNT 30 /* should be a multiple of 3 */
#define EBUFLEN 128
#define BUFLEN 1024

int main002()
{
    pcre  *re;
    const char *error;
    int  erroffset;
    int  ovector[OVECCOUNT];
    int  rc,i;
    char  src [] = "111 <title>Hello World</title> 222";   // 要被用来匹配的字符串
    char  pattern [] = "<title>(.*)</(tit)le>";              // 将要被编译的字符串形式的正则表达式
    printf("String : %s\n",pattern);
    re = pcre_compile(pattern,// pattern,输入参数,将要被编译的字符串形式的正则表达式
                      0,// options,输入参数,用来指定编译时的一些选项
                      &error,// errptr,输出参数,用来输出错误信息
                      &erroffset,// erroffset,输出参数,pattern中出错位置的偏移量
                      NULL);        // tableptr,输入参数,用来指定字符表,一般情况用NULL
    // 返回值:被编译好的正则表达式的pcre内部表示结构
    if (re == NULL) {                 //如果编译失败,返回错误信息
        printf("PCRE compilation Failed at offset %d: %s\n",error);
        return 1;
    }
    rc = pcre_exec(re,// code,输入参数,用pcre_compile编译好的正则表达结构的指针
                   NULL,// extra,输入参数,用来向pcre_exec传一些额外的数据信息的结构的指针
                   src,// subject,输入参数,要被用来匹配的字符串
                   strlen(src),// length,输入参数, 要被用来匹配的字符串的指针
                   0,// startoffset,输入参数,用来指定subject从什么位置开始被匹配的偏移量
                   0,输入参数, 用来指定匹配过程中的一些选项
                   ovector,// ovector,输出参数,用来返回匹配位置偏移量的数组
                   OVECCOUNT);    // ovecsize,输入参数, 用来返回匹配位置偏移量的数组的最大大小
    // 返回值:匹配成功返回非负数,没有匹配返回负数
    if (rc < 0) {                     //如果没有匹配,返回错误信息
        if (rc == PCRE_ERROR_NOMATCH)
            printf("Sorry,no match ...\n");
        else
            printf("Matching error %d\n",rc);
        pcre_free(re);
        return 1;
    }
    printf("\nOK,has matched ...\n\n");   //没有出错,已经匹配
    for (i = 0; i < rc; i++) {             //分别取出捕获分组 $0整个正则公式 $1第一个()
        char *substring_start = src + ovector[2*i];
        int substring_length = ovector[2*i+1] - ovector[2*i];

        printf("$%2d: %.*s\n",substring_start);
    }

    pcre_free(re);                     // 编译正则表达式re 释放内存
    return 0;
}

c语言正则表达式库pcre使用例子的更多相关文章

  1. HTML5数字输入仅接受整数的实现代码

    这篇文章主要介绍了HTML5数字输入仅接受整数的实现代码,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下

  2. html5录音功能实战示例

    这篇文章主要介绍了html5录音功能实战示例的相关资料,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧

  3. 使用最新的Flurry SDK和ios4重新启动应用程序

    我真的希望这对我来说只是一个愚蠢的错误.我很高兴使用Flurry但这样的事情会导致我的应用被拒绝.解决方法我写了关于这个的Flurry,他们很快回到我身边,他们会调查这个.大约一个星期后,他们回信并表示他们已经在v2.6中修复了它,现在可用了.我似乎无法重现这个问题.不是说我很棒或者什么,但我还是单枪匹马地解决了这个问题.

  4. 为什么这个OpenGL ES 2.0着色器不能在iOS上使用我的VBO?

    如果有人能够了解这里出了什么问题,也许是对gl命令或其他一些不兼容的命令序列的错误排序,我将非常感谢你的帮助.尽管谷歌在“OpenGLES2.0编程指南”中进行了大量研究和研究,但我一直试图让这段代码整天都没有成功.我正在尝试在iPhone上的OpenGLES2.0中使用顶点缓冲区对象和自定义着色器.我试图交错来自以下类型的一系列自定义结构的顶点数据:位置,半径和颜色字节分别考虑顶点位置,点大小和

  5. ios – 使用大写符号在字符串swift中获取URL的正则表达式

    我尝试在文本中获取URL.所以,在此之前,我使用了这样一个表达式:但是当用户输入带有大写符号的URL时(例如Http://Google.com,它与它不匹配)我遇到了问题.我试过了:但什么都没发生.解决方法您可以使用正则表达式中的i内联标志关闭区分大小写,有关可用正则表达式功能的详细信息,请参阅FoundationFrameworkReference.(?ismwx-ismwx)Flagsetti

  6. 如何在Xcode 4.1中调试OpenCL内核?

    我有一些OpenCL内核没有做他们应该做的事情,我很想在Xcode中调试它们.这可能吗?当我在我的内核中使用printf()时,OpenCL编译器总是给我一大堆错误.解决方法将格式字符串转换为constchar*似乎可以解决此问题.这适用于Lion:这有上述错误:

  7. ios – 如何在Swift 3中使用正则表达式?

    解决方法我相信.当没有其他选项适用时,将使用.allZeros.因此,使用Swift3,您可以传递一个空的选项列表或省略options参数,因为它默认为无选项:要么请注意,在Swift3中,您不再使用error参数.它现在抛出.

  8. ios – lldb断点在类目标c中的所有方法

    如何使用lldb在ObjectiveC类中的所有方法上自动设置断点?

  9. ios – 将两个字符串转换为一组布尔值的快速方法是什么?

    我有一个长字符串,我想转换为一个布尔值数组.而且它需要很多次,很快.我天真的尝试是这样的:但这比我想要的要慢很多.我的剖析告诉我,地图是减速的地方,但我不知道我能做多么简单.我觉得如果没有Swift’s/ObjC的开销,这样做会很快.在C中,我认为这是一个简单的循环,其中一个字节的内存与一个常量进行比较,但我不知道我应该看的是什么函数或语法.有更好的办法吗?

  10. 在iOS上默认是char签名还是未签名?

    默认情况下,iOS上是否签名或未签名?(我认为这将是一个很好的回答问题,但奇怪的是谷歌没有任何用处!

随机推荐

  1. 法国电话号码的正则表达式

    我正在尝试实施一个正则表达式,允许我检查一个号码是否是一个有效的法国电话号码.一定是这样的:要么:这是我实施的但是错了……

  2. 正则表达式 – perl分裂奇怪的行为

    PSperl是5.18.0问题是量词*允许零空间,你必须使用,这意味着1或更多.请注意,F和O之间的空间正好为零.

  3. 正则表达式 – 正则表达式大于和小于

    我想匹配以下任何一个字符:或=或=.这个似乎不起作用:[/]试试这个:它匹配可选地后跟=,或者只是=自身.

  4. 如何使用正则表达式用空格替换字符之间的短划线

    我想用正则表达式替换出现在带空格的字母之间的短划线.例如,用abcd替换ab-cd以下匹配字符–字符序列,但也替换字符[即ab-cd导致d,而不是abcd,因为我希望]我如何适应以上只能取代–部分?

  5. 正则表达式 – /bb | [^ b] {2} /它是如何工作的?

    有人可以解释一下吗?我在t-shirt上看到了这个:它似乎在说:“成为或不成为”怎么样?我好像没找到’e’?

  6. 正则表达式 – 在Scala中验证电子邮件一行

    在我的代码中添加简单的电子邮件验证,我创建了以下函数:这将传递像bob@testmymail.com这样的电子邮件和bobtestmymail.com之类的失败邮件,但是带有空格字符的邮件会漏掉,就像bob@testmymail也会返回true.我可能在这里很傻……当我测试你的正则表达式并且它正在捕捉简单的电子邮件时,我检查了你的代码并看到你正在使用findFirstIn.我相信这是你的问题.findFirstIn将跳转所有空格,直到它匹配字符串中任何位置的某个序列.我相信在你的情况下,最好使用unapp

  7. 正则表达式对小字符串的暴力

    在测试小字符串时,使用正则表达式会带来性能上的好处,还是会强制它们更快?不会通过检查给定字符串的字符是否在指定范围内比使用正则表达式更快来强制它们吗?

  8. 正则表达式 – 为什么`stoutest`不是有效的正则表达式?

    isthedelimiter,thenthematch-only-onceruleof?PATTERN?

  9. 正则表达式 – 替换..与.在R

    我怎样才能替换..我尝试过类似的东西:但它并不像我希望的那样有效.尝试添加fixed=T.

  10. 正则表达式 – 如何在字符串中的特定位置添加字符?

    我正在使用记事本,并希望使用正则表达式替换在字符串中的特定位置插入一个字符.例如,在每行的第6位插入一个逗号是什么意思?如果要在第六个字符后添加字符,请使用搜索和更换从技术上讲,这将用MatchGroup1替换每行的前6个字符,后跟逗号.

返回
顶部