Ugleh
Ugleh

Reputation: 3

In Java, how do i search for this certain regex?

I want a function to search a string to see if it contains $[0-9] or $[a-f,A-F]

So like, if it contains $a or even $e it'll turn true.

Upvotes: 0

Views: 137

Answers (3)

Mark Thomas
Mark Thomas

Reputation: 37517

The regex is /\$[A-Fa-f0-9]/ and you might use it like so:

Pattern.matches("\$[A-Fa-f0-9]", yourString);

See http://download.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html

Upvotes: 2

Related Questions