Regex not working

I need a regex for allowing only numbers + following characters (+, , ( ,) )

I have done this :

^-{0,1}\d+$

But this is taking only numbers ..how we can write it for the charecters as well?

Answers


Try the following:

^[0-9-.+ ()]+$

This would be the solution:

^[0-9\+\s\(\)]+$

Regex Demo


Need Your Help

Convert from unicode in jsp for JSON's eval function

json jsp unicode

Im getting a string (simplified) from the backend that should be :

Preventing access to subsequent pages not proceeding current

php forms codeigniter session access-control

I have a codeigniter MVC setup where a piece of a form exists on one page.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.