Open main menu

Wikibooks β

REBOL Programming/Language Features/Parse/Splitting using specific delimiters

< REBOL Programming‎ | Language Features‎ | Parse

The parse string none expression breaks down when:

  • you want to specify which characters shall be treated as whitespace
  • you want to specify which characters shall be treated as delimiters
  • you don't want the quotation marks to be handled specially
  • you need something other than simple splitting



These examples show, how you can influence how the PARSE function handles whitespace, or how you can use specific delimiters, instead of the default ones.

To eliminate the special treatment of whitespace use the /ALL PARSE refinementEdit

parse/all "only common delimiters; split the text, now" none
; == ["only common delimiters" " split the text" " now"]

If you have different delimiter(s) you can supply a string rule to PARSE containing your delimiters.

The #"#" character as a delimiterEdit

parse "red#blue#green" "#"
; == ["red" "blue" "green"]

The space character as a delimiterEdit

parse/all "red blue^-green" " "
; == ["red" "blue^-green"]

The #"#" and #"*" characters as delimitersEdit

parse "red#blue*green" "#*"
; == ["red" "blue" "green"]

Note that the order of the characters in the delimiter string is not important.