Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

All the evidence concerning the universe has not yet been collected, so there's still hope.


devel / comp.lang.lisp / .Re: string splitting problem

SubjectAuthor
o .Re: string splitting problemRobert L.

1
.Re: string splitting problem

<sv803v$1ofa$1@gioia.aioe.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=16923&group=comp.lang.lisp#16923

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!aioe.org!mhnTAX5IWdp00sAAh3yfnA.user.46.165.242.75.POSTED!not-for-mail
From: No_spamming@noWhere_7073.org (Robert L.)
Newsgroups: comp.lang.lisp
Subject: .Re: string splitting problem
Date: Thu, 24 Feb 2022 13:10:24 -0000 (UTC)
Organization: Aioe.org NNTP Server
Message-ID: <sv803v$1ofa$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Injection-Info: gioia.aioe.org; logging-data="57834"; posting-host="mhnTAX5IWdp00sAAh3yfnA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: XanaNews/1.18.1.6
X-Notice: Filtered by postfilter v. 0.9.2
 by: Robert L. - Thu, 24 Feb 2022 13:10 UTC

Pascal Bourguignon wrote:

> > I have to split a string from /proc/net/arp of the format
> > "127.0.0.1 0x1 0x2 00:11:22:33:AE:5E * ethx"
> > ^^^
> > to extract the MAC.
>
>
> When I don't need the utmost efficient solution, I merely use:
>
> [69]> (split-string (fourth (delete "" (split-string line " ")
> :test (function string=))) ":")
> ("00" "11" "22" "33" "AE" "5E")
>
>
> with (GPL sources):
>
> (DEFUN SPLIT-STRING (STRING &OPTIONAL (SEPARATORS " "))
> "
> NOTE: current implementation only accepts as separators
> a string containing literal characters.
> "
> (UNLESS (SIMPLE-STRING-P STRING) (SETQ STRING (COPY-SEQ STRING)))
> (UNLESS (SIMPLE-STRING-P SEPARATORS) (SETQ SEPARATORS (COPY-SEQ SEPARATORS)))
> (LET ((CHUNKS '())
> (POSITION 0)
> (NEXTPOS 0)
> (STRLEN (LENGTH STRING)) )
> (DECLARE (TYPE SIMPLE-STRING STRING SEPARATORS))
> (LOOP WHILE (< POSITION STRLEN)
> DO
> (LOOP WHILE (AND (< NEXTPOS STRLEN)
> (not (position (CHAR STRING NEXTPOS) separators)))
> DO (SETQ NEXTPOS (1+ NEXTPOS))
> );;loop
> (PUSH (SUBSEQ STRING POSITION NEXTPOS) CHUNKS)
> (SETQ POSITION (1+ NEXTPOS))
> (SETQ NEXTPOS POSITION)
> );;loop
> (NREVERSE CHUNKS)
> );;let
> );;SPLIT-STRING

Gauche Scheme and Racket:

;; For Gauche
(use srfi-1) ;; fourth
(use srfi-13) ;; string-tokenize
(use srfi-14) ;; character sets

;; For Racket
(require srfi/13) ;; string-tokenize
(require srfi/14) ;; character sets

(define (get-mac line)
(string-tokenize
(fourth (string-tokenize line char-set:graphic))
char-set:hex-digit))

(get-mac
"127.0.0.1 0x1 0x2 00:11:22:33:AE:5E * ethx")
====>
("00" "11" "22" "33" "AE" "5E")


devel / comp.lang.lisp / .Re: string splitting problem

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor