2
0
mirror of https://github.com/boostorg/build.git synced 2026-02-16 01:12:13 +00:00
Files
build/v2/util/regex.jam
Dave Abrahams bfbb5533d9 some small progress made
[SVN r11760]
2001-11-21 04:47:44 +00:00

34 lines
986 B
Plaintext

# (C) Copyright David Abrahams 2001. Permission to copy, use, modify, sell and
# distribute this software is granted provided this copyright notice appears in
# all copies. This software is provided "as is" without express or implied
# warranty, and with no claim as to its suitability for any purpose.
rule split ( string separator )
{
local result ;
local s = $(string) ;
while $(s)
{
local match = [ SUBST $(s) ^(.*)$(separator)(.*) $1 $2 ] ;
local tail = $(match[2]) ;
tail ?= $(s) ;
result = $(tail) $(result) ;
s = $(match[1]) ;
}
return $(result) ;
}
rule __test__ ( )
{
import assert ;
assert.result a b c : split "a/b/c" / ;
assert.result a b c : split "/a/b/c" / ;
assert.result "" a b c : split "//a/b/c" / ;
assert.result a "" b c : split "/a//b/c" / ;
assert.result a "" b c "" : split "/a//b/c/" / ;
assert.result a "" b c "" "" : split "/a//b/c//" / ;
}