This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

How to split this $arg ?

Old posts that have not been replied to for several years.
Locked
S
SkiRmiS

Post by SkiRmiS »

Hija,
How to split this :
$arg="mail@mail.com messagesstext" into $mail="mail@mail.com" ; $message="everything after email adress"
Thanks in advice

Bye
P
Petersen
Owner
Posts: 685
Joined: Thu Sep 27, 2001 8:00 pm
Location: Blackpool, UK

Post by Petersen »

set mail [lindex [split $arg] 0]
set message [join [lrange [split $arg] 1 end]]
<font size=-1>[ This Message was edited by: Petersen on 2002-01-08 14:52 ]</font>
S
SkiRmiS

Post by SkiRmiS »

Thank you :]
e
egghead
Master
Posts: 481
Joined: Mon Oct 29, 2001 8:00 pm
Contact:

Post by egghead »

Assuming your $arg is a one line string, you could try:

Code: Select all


scan $arg "%s %[^n]" mail message

M
Mata Hari

Post by Mata Hari »

added note

the split will kill multiple spaces, you can use a more general solution using:

Code: Select all

set mail "[string range $arg 0 [expr ([string first " " $arg] - 1)]]"
set message "[string range $arg [expr ([string first " " $arg] + 1)] end]"
also fixed the n problem


_________________
<sig>
This is a Signature virus, please place me in your signature so I can spread
</sig>

<font size=-1>[ This Message was edited by: Mata Hari on 2002-01-13 17:31 ]</font>
Locked