Regcomp?

This is a discussion on Regcomp? within the C Programming forums, part of the General Programming Boards category; I'm making my first C script, it logs on to a website and checks if it succeeded. Therefor, I need ...

  1. #1
    Registered User
    Join Date
    Oct 2006
    Posts
    17

    Regcomp?

    I'm making my first C script, it logs on to a website and checks if it succeeded. Therefor, I need to check if the page contains "Je bent nu ingelogd". The website is saved in char *res.

    Can anyone help? I wanted to use regcomp but I didn't understand the man page and I couldn't find any good example on this site or google.

    Thanks!

  2. #2
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    Write your own search function.
    It isn't so hard.
    "The Internet treats censorship as damage and routes around it." - John Gilmore

  3. #3
    Registered User
    Join Date
    Oct 2006
    Posts
    17
    Well, for me it is, this is my first C script 8-)

  4. #4
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    Go back to Hello World and tutorials then!
    "The Internet treats censorship as damage and routes around it." - John Gilmore

  5. #5
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >Write your own search function.
    >It isn't so hard.
    The actual search isn't terribly difficult, but connecting to a web server and downloading the contents of a page isn't exactly trivial.

    >Well, for me it is, this is my first C script 8-)
    You probably don't want to do it in C. I would tend more toward Perl for something like this.
    My best code is written with the delete key.

  6. #6
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    I wouldn't use scripting languages in real programs.
    I would use scripting languages in web sites.

    This is some kind of a search function. It is terrible and may be buggy, so beware:
    Code:
    int search(char* data,char* find){
        int i,match=0,findlen,start;
        if(find[0]=='\0'){
            return -1;
        }
        findlen=strlen(find);
        for(i=0;data[i]!='\0';i++){
            if(data[i]==find[match]){
                if(match==0){
                    start=i;
                }
                match++;
                if(match==findlen){
                    return start;
                }
            }
            else{
                if(match>0){
                    match=0;
                    if(data[i]==find[0]){
                        start=i;
                        match=1;
                        if(findlen==1){
                            return start;
                        }
                    }
                }
                else{
                    match=0;
                }
            }
        }
        return -1;
    }
    If the second string is found in the first string, then it returns the location where it starts.
    Otherwise it returns -1.
    "The Internet treats censorship as damage and routes around it." - John Gilmore

  7. #7
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >I wouldn't use scripting languages in real programs.
    Why not?

    >This is some kind of a search function. It is terrible and may be buggy, so beware:
    It's a good thing standard C provides strstr.
    My best code is written with the delete key.

  8. #8
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    Code:
    Why not?
    Because it is a SCRIPTING language, not a PROGRAMMING language. It needs INTERPRETER.

    I have already told it's a lot more fun to make the whole function myself.
    Last edited by maxorator; 10-15-2006 at 02:19 PM.
    "The Internet treats censorship as damage and routes around it." - John Gilmore

  9. #9
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >Because it is a SCRIPTING language, not a PROGRAMMING language. It needs INTERPRETER.
    Excuse me, I need to go beg webmaster for a "stunned silence" smiley.

    >I have already told it's a lot more fun to make the whole function myself.
    I don't have a problem with that. What I have a problem with is your completely ignoring a better solution and making a beeline to your own naive code. You can post your own implementation if you want, but please do so after properly answering the question to the best of your ability.
    My best code is written with the delete key.

  10. #10
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    You should have seen by now that every single thing maxorator says is ... I can't even locate the correct word. Inept? Pointless? Wrong? Eye-bleed-inducing? I'm going to have to start making up words for it.


    Quzah.
    Hope is the first step on the road to disappointment.

  11. #11
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >I'm going to have to start making up words for it.
    Just call him a Mister C and be done with it. Ah, I kill me. That reminds me to read his book on C#...
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Hexadecimal Characters in RegEx
    By maestro371 in forum C Programming
    Replies: 10
    Last Post: 04-13-2008, 04:27 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21