yuguang
yuguang

Reputation: 231

Scheme regular expression match

Is there a simpler way of writing in scheme

(eqv? (regexp-match "0x" "0x1234") #t)

#f

(eqv? (regexp-match "0x" "1234") #f)

#t

Upvotes: 1

Views: 668

Answers (1)

Eli Barzilay
Eli Barzilay

Reputation: 29546

That would be

(regexp-match? #rx"0x" "...some-string...")

Note that the #rx means that the regexp is precompiled and included in your code. It's also better to do that since it protects you from writing confused code and swapping the arguments.

BTW, something like

(regexp-match? #rx"^0x" "...some-string...")

is probably more useful.

See also the Guide pages to learn how to use regular expressions in PLT, and the reference page for a complete description.

Upvotes: 1

Related Questions