Shoutbox

searching some letters or words in sentence... - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: searching some letters or words in sentence... (/showthread.php?tid=66438)

searching some letters or words in sentence... by genesistr on 09-19-2006 at 04:28 PM

hmm acctually i know how i must write the code but i dont know how i can do this...

a="hello";

how can i split this into letters... i mean in C.. its like this...
a[]="hello";
and i can call which one i want...
like a[2]=? ...
but in script i dont how can i...

exp...
word="this is an example";
search="an";

i want script to say "Word" include "search" or not...


RE: searching some letters or words in sentence... by mezzanine on 09-19-2006 at 05:09 PM

This C code snippet will attempt to find the first occurence of needle in haystack. For reference, the strstr function returns a pointer to the first occurence of needle in haystack, or NULL if the needle is not found.

code:
#include <stdio.h>
#include <string.h>

main() {
char haystack[] = "This is our sentence";
char needle[] = "se";
if (strstr(haystack, needle)) printf("Found needle in haystack.");
    else printf("Not found.");
}



RE: searching some letters or words in sentence... by Silentdragon on 09-19-2006 at 05:16 PM

code:
var word = "this is an example";
if(word.match(/an/) != null){
        // contains an
}

RE: searching some letters or words in sentence... by genesistr on 09-19-2006 at 07:10 PM

thx...
i can already write in C.. anyway thx..

and SilenDragon thx :) thats the wat i want...