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

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

Examples edit

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 refinement edit

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 delimiter edit

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

The space character as a delimiter edit

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

The #"#" and #"*" characters as delimiters edit

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

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