Results 1 to 6 of 6

Thread: Searching for specific text in a string

  1. #1

    Searching for specific text in a string

    For the anti-myg0t plugin I've gotten back to work on, all I need to do is set it up so it will scan a specific string for the term "[myg0t]" and then do the given actions. This would be most easily explained in C, as Small(the scripting language used for Admin mod) is most similar to that in terms of syntax.





    Also, if you want to know about myg0t:


    http://www.pwned.nl/



    Except for the fact that they also hack and crash servers. They seem to be down for now, but you never know when they decide come back.
    Tell me if you think I\'m spamming or doing something stupid, please.

  2. #2
    Senior Member
    Join Date
    Nov 2001
    Posts
    1,255
    Was there a question there?
    Chris Shepherd
    The Nelson-Shepherd cutoff: The point at which you realise someone is an idiot while trying to help them.
    \"Well as far as the spelling, I speak fluently both your native languages. Do you even can try spell mine ?\" -- Failed Insult
    Is your whole family retarded, or did they just catch it from you?

  3. #3
    Umm... I sort of forgot the question...






    The question is, how do you search for specific text in a string? An example in C would be the greatest help.
    Tell me if you think I\'m spamming or doing something stupid, please.

  4. #4
    AntiOnline n00b
    Join Date
    Feb 2004
    Posts
    666
    Hi

    I have no idea what anti-myg0t plugin is and the site URL you gave takes ages to load on my slow-dial up.

    The question is, how do you search for specific text in a string? An example in C would be the greatest help.
    So you want to write a program in C which fiands a Substring in a given string right say

    The String is Was there a question there?

    and you want to find whether a string question is there in it

    thats fairly simple and there are many ways to do it

    First and the simplest i belive is to use the function strstr which finds the first occurance of a substring in a given string..........the syntax would be

    result=strstr(string1,string2)

    the result would return a pointer to the location of the first character of the first occurance of the substring n the string ......else it returns NULL.......now you can modify that to suit your neeeds for examle you found the first occcurence and want to find whether it is there again or not etc etc.....

    Or second would be go the long way without using these string functions ...............search for the ocurance of the first character of the substring in the string......for example talking the above string and substring searh for "q" in the string Was there a question there? when you find "q" run a loop 7 time strlen(question) and see if rest of the the 7 characters after that "q" are similar if yes success else not found ....try it your self if you have any problem let us know........

    --Good Luck--

  5. #5
    Ok... as usual, I didn't get much out of what you said(being that C is an evil language, IMO, and that the scripting language used for Admin Mod is most similar to C... yea...)



    So the strstr searches the two strings given for the first occurance of the substring? And then returns a pointer?



    Excuse my n00bness, but what's a pointer?
    Tell me if you think I\'m spamming or doing something stupid, please.

  6. #6
    AntiOnline n00b
    Join Date
    Feb 2004
    Posts
    666
    HI,

    So the strstr searches the two strings given for the first occurance of the substring? And then returns a pointer?
    Yes.

    It is a Function that takes two arguments both strings and returns a pointer to the occurance of the first argumrnt in the second ............else returns NULL

    Excuse my n00bness, but what's a pointer?
    Pointer is a variable that contains the address of another variable.

    e.g

    when you declare a variable say char str[5]

    5 consicutive locations are allocated for str in the memory.........all of them can be independently addressed........when i say

    ptr= &str;

    The base address of the variable str (first of the 5 consituve location) will be passd on to the ptr.................ptr is a pointer to str

    Hope this helps .......



    --Good Luck--

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •