Reputation: 3
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
Reputation: 548
create regex with the help of this tutorial : http://download.oracle.com/javase/tutorial/essential/regex/matcher.html
use matches() method from String class : http://download.oracle.com/javase/7/docs/api/java/lang/String.html#matches%28java.lang.String%29
Upvotes: 0
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