john123
john123

Reputation: 589

regular expression pattern

I would like to create a pattern, which matches all ASCii decimal codes from 58 to 64 (include 58 and 64)

String regExp=""; //ASCii decimal codes 58 - 64

//How to define above regular expression string "regExp"

Pattern pattern = Pattern.compile(regExp);

How to define the regular expression string regExp ?

Upvotes: 1

Views: 297

Answers (3)

Yes Barry
Yes Barry

Reputation: 9856

Here is with raw ASCII numeric values.

String regExp = "[\\x3A-\\x40]+";

Should match all occurrences.

Upvotes: 2

Brian Agnew
Brian Agnew

Reputation: 272307

If you want to use numeric values, try

String regexp = "[\\x3a-\\x40]";

You can't specify decimal values, unfortunately. See the Pattern doc for more info.

Upvotes: 3

Olaf Dietsche
Olaf Dietsche

Reputation: 74058

Just use a character class:

String regExp="[:;<=>?@]";

Upvotes: 1

Related Questions