Computing.Net > Forums > Programming > Java Regular exp to check string

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Java Regular exp to check string

Reply to Message Icon

Name: sujie
Date: July 11, 2007 at 04:10:27 Pacific
OS: Windows
CPU/Ram: 1 GB
Product: microsoft
Comment:

Hi,

I need to have a validation in my Java program on a string. The string cannot contain special characters other than .(dot),_(underscore), -(hyphen).

name.matches("/[a-zA-Z0-9]/g")
I tried this and it does not work ..
could somebody suggest me what regular expression i need to use..

Thanks,

Sujie



Sponsored Link
Ads by Google

Response Number 1
Name: Razor2.3
Date: July 12, 2007 at 20:56:31 Pacific
Reply:

I'd try something like this:
"/[^a-zA-Z0-9\._\-]/g


0
Reply to Message Icon

Related Posts

See More


Batch file for drive Batch to send a text mess...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Java Regular exp to check string

How to check if a file is opened www.computing.net/answers/programming/how-to-check-if-a-file-is-opened/6494.html

read from file to check for duplicates www.computing.net/answers/programming/read-from-file-to-check-for-duplicates/19032.html

Append to a string www.computing.net/answers/programming/append-to-a-string/3777.html