Commit bd1d5a36 authored by bp's avatar bp
Browse files

Regexp replacement improved

git-svn-id: https://forth-ev.de/repos/bigforth@1678 3b8d8251-53f3-0310-8f3b-fd1cb8370982
parent e37b7e80
......@@ -101,4 +101,15 @@ s" fofoofoofofooofoobarbar" ?foos1
s" bla baz bar" ?foos1
s" foofoofoo" ?foos1
\ replacement tests
: hms>s ( addr u -- addr' u' )
s// \( \d \d \) ` : \( \d \d \) ` : \( \d \d \)
\1 s>number drop 60 *
\2 s>number drop + 60 *
\3 s>number drop + 0 <# 's' hold #s #> //g ;
s" bla 12:34:56 fasel 00:01:57 blubber" hms>s
s" bla 45296s fasel 117s" str= 0= [IF] .( failed) [THEN]
script? [IF] bye [THEN]
......@@ -190,6 +190,7 @@ Variable >>string
swap 2dup >>string $@ drop -rot move
>>string $off 0 to >>ptr 0 to <<ptr ;
: >>next ( -- addr u ) <<ptr end$ over - ;
: s// ]] BEGIN [[ ; immediate
: //g ]] WHILE >>next REPEAT end$ [[
s" " ]] SLiteral << >>string@ rot drop [[ ; immediate
: >>rest ( -- ) >>next >>string $+! ;
: s// ( addr u -- ptr ) ]] (( // >> [[ ; immediate
: // ( ptr addr u -- addr' u' ) ]] << )) drop >>rest >>string@ [[ ; immediate
: //g ( ptr addr u -- addr' u' ) ]] << LEAVE )) drop >>string@ [[ ; immediate
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment