/explode - Split text

By Jonesy44 on Apr 13, 2009

Introduction Updated, new $explode feature.
Serves the same purpose as the PHP explode() function.
Syntax:

  • /explode /explode [charval_to_seperate] [text_to_explode]
    -- exploded text is set to %explode with /explode
  • $explode(text_to_explode).charval_to_seperate
    -- exploded text returned if $explode is used

No screenshot available
Image

; -------------------------------
; Improved Regsubex version
alias explode {
  ; syntax:/explode [charval_to_seperate] [text_to_explode] 
  ;     or: $explode(text_to_explode).Charval_to_seperate
  ;   exploded text is set to %explode with /explode
  ;   exploded text returned if $explode is used
  ; ---
  var %tx = $iif($isid,$1-,$2-), %cn = $iif($isid,$prop,$1)
  if (%cn !isnum 1-255) $iif($isid,return,echo -a) 2* $+($iif($isid,$,/),explode:) error. invalid paramaters
  else $iif($isid,return,set %explode) $left($regsubex(%tx,/(.)/g,$+(\t,$chr(%cn))),-1)
}

; OLD EXPIRED VERSION - HERE FOR REFERENCE
; --------------------------
; While loop version
alias explode {
  ; syntax:/explode [text_to_explode] [charval_to_seperate]
  ; exploded text is set to %explode
  ; ---
  if ($gettok($1-,$0,32) !isnum 1-255) { echo -a 2* /explode: error syntax:/explode texttoexplode [chrvaltoseperate] }
  unset %explode | var %x = 1
  while (%x <= $len($1)) { set %explode %explode $+($mid($1,%x,1),$chr($gettok($1-,$0,32))) | inc %x }
}
;---------------------------

Comments

Sign in to comment.
Jonesy44   -  Dec 08, 2009

$gettok(%explode,tok(s),chrval)

 Respond  
[Plornt]   -  Dec 08, 2009

Oh i thought it litrally split the text up like the pphp does into arrays but all it seems to be doing for me is putting in aload of spaces (and because i wanted to separate -) and aload of - in there too.

Serves the same purpose as the PHP explode() function.

What i usually use the explode function on php is to split a sting into chunks into an array using the character you specify, kind of like tokenize in mirc.

And i just realised, why the fudge dont i just use tokenize

 Respond  
Jonesy44   -  Dec 08, 2009

Use the regsub version. It's much faster. Glad to help.

 Respond  
[Plornt]   -  Dec 06, 2009

omfg Thank you, this is what ive always wanted but coudnt be arsed to make it :O :D

 Respond  
Jonesy44   -  Jul 10, 2009

Updated, new $explode feature.
Serves the same purpose as the PHP explode() function.
Syntax:

  • /explode /explode [charval_to_seperate] [text_to_explode]
    -- exploded text is set to %explode with /explode
  • $explode(text_to_explode).charval_to_seperate
    -- exploded text returned if $explode is used
 Respond  
Jonesy44   -  May 04, 2009

i used it a few times when i made a website with user databases.

 Respond  
^Neptune   -  May 04, 2009

Hehe explode() was one of the first things I pissed around with when I was first learning PHP cause I wanted to replicate tokens in mIRC.

 Respond  
Jonesy44   -  May 04, 2009

Problem fixed. the gettok, is so the last token is always selected rather than just the second token because the command "/explode explode this text 44" would not work otherwise

 Respond  
Blitzjager   -  May 04, 2009

Seems to separate by a space no matter what. And I think the $gettok($1,$0,32) should just be $2. Could see a few places I would use it.

 Respond  
Jonesy44   -  May 04, 2009

Testor: A charval is a character ASCII value. check help files "$chr" and "$asc". For example the character value for a space is 32.

bone282: Yeah it's a shame it can't be expanded into a better language since it's so simple to learn, has a great help manual etc.

tv3636: Ty :) care to rate? ;)

 Respond  
tv3636   -  May 03, 2009

Very useful little snippet :)

 Respond  
bone282   -  May 03, 2009

lol

 Respond  
PATX   -  May 03, 2009

first off: PHP is a scripting lang. (just like mIRC)

second off: PHP is very bad. (it gets you into a scripting pattern) :(

third off: bone282: I find the word you used for a womens breast inappropriate. Even tho I am a (straight) guy.

 Respond  
bone282   -  May 03, 2009

of course, it's the main other language i use, even though i hardly do it these days.
I used to code mIRC a long time ago. but, i really don't see the point in applying all that time and effort into a language thats of no use outside of mIRCLAND. Thats just my opinion though. Not trying to get on anyones tits. :P

 Respond  
Testor   -  May 03, 2009

WTH is a charval /noob question

 Respond  
Jonesy44   -  May 03, 2009

of course, it's the main other language i use, even though i hardly do it these days.

 Respond  
bone282   -  May 02, 2009

nice to see someones still thinking about php

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.