select before and after text
#1

How would i get text before and after a character....

For example
PHP код:
hello,ic3_cr3am 
How would i get text before and after ',' (comma)
Reply
#2

not sure just made this not tested but might work
pawn Код:
#define Seprate "hello,ic3_cr3am"// storing the variable to seprate

new pos=strfind(Seprate, ",", true);//finding how far comma is from start

new str1[30],str2[30];
strmid(str1,SEPRATE,0,pos);//extracting characters before comma that will be stored in str1
strmid(str2,SEPRATE,pos+1,strlen(SEPRATE));//extracting characters after comma that will be stored in str2
Reply
#3

Or simply:
pawn Код:
sscanf(text, "p<,>s[16]s[16]", part1, part2)
Reply
#4

if this is with PHP use preg_match!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)