views:

97

answers:

2

I want to split a string based on a non-regular expression. My input is a plain string. So, for example, given the input "hello.*there" and ".*", I want the result ("hello" "there").

Doing this obv doesn't work:

(regexp-split (regexp sep) str))

since it will try to match the regular expression .*. How do I escape sep to nullify any regexp-like patterns?

+3  A: 

regexp-quote.

Eli Barzilay
+1  A: 

Claudiu, many of the questions you have asked about PLT-Scheme are answered in the documentation. Not to say it's wrong to ask questions, sometimes you'll get a more in-depth answer here.

There are many documents in the set of documentation that comes with PLT-Scheme. There are 2 pieces of documentation you want to be familiar with:

  1. The PLT Scheme Guide. http://docs.plt-scheme.org/guide/index.html
  2. The PLT Scheme Reference: http://docs.plt-scheme.org/reference/index.html

Both are installed locally when you install PLT-Scheme (formerly called DrScheme).

The Guide is intended for those new to Scheme or PLT-Scheme. The Reference is more in depth.

Eli pointed to the link in the Reference documentation. The regexp-quote function is also mentioned is the much shorter and more readable Guide, here http://docs.plt-scheme.org/guide/regexp-intro.html along with mention of quoting special characters using \, as well as a link to the Reference documentation.

z5h
thanks! my main problem is that i wasn't able to find a good link to the documentation by google searching, or the docs i found were for certain modules which i didn't know how to import. these are a good place to start though
Claudiu