validation « validation « Java Regex Q&A

Home
Java Regex Q&A
1.Development
2.find
3.group
4.Match
5.matcher
6.number
7.Operation
8.parse
9.Pattern
10.replace
11.validation
12.word
Java Regex Q&A » validation » validation 

1. How can I validate a name, middle name, and last name using regex in Java?    stackoverflow.com

I get a list of names and need to validate them. Some examples:

  • Elizabeth T. Bang
  • Elizabeth Bang
  • Zaki M. F. El-Adawy
  • joseph m. pastore, jr.
  • Zaki M. F. El-Adawy
How can I use regular expressions in ...

2. How do I make this regex more general, sometimes it works and sometimes it doesn't    stackoverflow.com

I have the following regex that I am using in a java application. Sometimes it works correctly and sometimes it doesn't.

<!-- <editable name=(\".*\")?> -->(.*)<!-- </editable> -->
Sometimes I will have whitespace before/after ...

3. How to validate data restriction using regex in java    stackoverflow.com

Hi I want to validate a string which donot have numeric characters. If my string is "javaABC" then it must be validated If my string is "java1" then it must ...

4. validate a string for text ,operators and ( [ ]) brackets    stackoverflow.com

i want a regular expression to validate string to have only text,operators and these brackets ([ ])

5. Java regex to validate a name    stackoverflow.com

To validate names that can be John, John Paul, etc. I use this regex:

String regex = "[A-Z]([a-z]+|\\s[a-z]+)";
but when I do:
boolean ok = Pattern.matches(regex, "John Paul");
the matches fail? Why? I want to use matches to ...

6. Regex / javax.validation help -- verifying non-whitespace present -- Java    stackoverflow.com

I'm trying to validate some fields before persisting them to the database. In particular, I need to know that a String contains a non-whitespace character. I'm using the javax.validation.constraints.Pattern annotation, as ...

7. What does the following ^.*$ regexp match?    stackoverflow.com

Can someone explain what the following regexp matches?

^.*$
Thank you!

8. Testing Java regex appendReplacement()    stackoverflow.com

I have developed a UI that allows users to define a regex pattern and then a replacement string that is used by appendReplacement(). e.g.

  • Pattern - 7(.*)
  • Replace pattern - $1
So 71234 would yield ...

9. java string regex    stackoverflow.com

could someone help me out with a piece of regex please? I want to stop the user entering any charachter other than a-z or a hyphen - Hope someone can help ...

10. How can I validate the range 1-99 using a regex?    stackoverflow.com

I need to validate some user input, to ensure a number entered is in the range of 1-99 inclusive. These must be whole (Integer) values Preceeding 0 is permitted, but optional Valid values

  1. 1
  2. 01
  3. 10
  4. 99
  5. 09
Invalid ...

11. Regular expression, calculate something like CRC in it with validations    stackoverflow.com

I have an array of bytes, I need to check if it starts with a specific number 0, terminates with 9 and in-between could be anything numbers, but after 9, I ...

12. regular expressions in Java    stackoverflow.com

i attempted to port the code in this answer to Java: PHP VIN number validation code i understand that String.matches in Java is a bit temperamental and i'm very unfamiliar with regular ...

13. Regular expression for validating an answer to a question    stackoverflow.com

Hey everyone, I'm having a minor difficulty setting up a regular expression that evaluates a sentence entered by a user in a textbox to keyword(s). Essentially, the keywords have to be entered ...

14. How to validate a Geometric point using a Java Regular Expression?    stackoverflow.com

I tried like this - To validate a point like x,y "[0-9]{1,},[0-9]{1,}" Its not working. UPDATE: I must be doing something wrong. This is a simple Console input through Scanner(System.in) - using Scanner#nextLine which returns ...

15. validate file java    stackoverflow.com

I have a flat file like:

A 10
S 20
W A 20 10
S A 45 10
S W S 20 20 20 30
W A S 22 50 20 55
I want to make sure it ...

16. Validation - Using regex and trim in java Strings    stackoverflow.com

Less of a question and more of a validation I guess but I have created a Java application to list the available networks, through linux, and I just wanted to see ...

17. Java XML Validator using REGEX and .split()    stackoverflow.com

Hey Guys I am building a Java XML validator without using the XML Schema which I notice is what people do. Don't ask why I am not using it. I have my ...

18. Blank spaces in regular expression    stackoverflow.com

I use this regular to validate many of the input fields of my java web app:

"^[a-zA-Z0-9]+$"
But i need to modify it, because i have a couple of fields that need to ...

19. Regular Expresion in Java for validating username    stackoverflow.com

I'm trying the username chains in Java with following rules:

  • Length >=3
  • Valid characters: a-z, A-Z, 0-9, points, dashes and underscores.
Could someone help me with the regular expression?

20. java regex for US State Validation    stackoverflow.com

I wrote this java method to do regex and missing something because it fails for all conditions. I am new to regex and unable to figure out whats causing it to ...

21. How to do Russian text validation in java using GNU's Regex..?    stackoverflow.com

I did internationalization for my website.So my website also available in Russian language.But while gathering user information of Russian user from my web page i am not able to validate entered ...

22. Validate File names    stackoverflow.com

File Format # [filename].[2 letter locale].[outputformat - html/subject/text].xml Valid filenames - myname.en.html.xml myname2.pt.subject.xml etc. Also, filenames are coming from a column in the database. Can somebody help me with the regex? Thank You! Edit# as per @drf

public static ...

23. Java Reg-ex to validate file convention    stackoverflow.com

How to check if the following is part of the file name using regular expressions

.en.
.fr.
.pt.
.de.
.ja.
.es.
.it.
.cn.
I know one other way is to check the index of and return boolean.

24. validate Regular Expression using Java    stackoverflow.com

I need validate a String using a Regular Expression, the String must be like "createRobot(x,y)", where x and y are digits. I have Something like

    String ins; 

 ...

25. Java regex validating special chars    stackoverflow.com

This seems like a well known title, but I am really facing a problem in this. Here is what I have and what I've done so far. I have validate input string, these ...

26. Java regex validating \[]    stackoverflow.com

My issues is to allow only a-z, A-Z, 0-9, points, dashes and underscores and [] for a given string. Here is my code but not working so far. [a-zA-Z0-9._-]* this one works ok ...

27. regular expression validating string    stackoverflow.com

I tried using this pattern

^[A-z]*[A-z,-, ]*[A-z]* 
To match against a string that starts with multiple alpha characters (a-z) followed by multiple hyphens or spaces and ends with alpha characters, eg:
Azasdas- ...

29. Validation using Regex    coderanch.com

30. REgular Expression for string validation    coderanch.com

Hi I had a look at the class String, if there exist such methods. Till now I did not get a usefull idea. Once I thought, maybe you could the method: public char[] toCharArray() Then you have to parse an array. Probably there might be for each test one loop. example: for (int i = 0; i

31. Regex validation    coderanch.com

Hi, I have a String of between 1 and 5 chars in length. It must contain at least one alphabetic character (i.e. a-zA-Z). The rest can be numeric or spaces. Is is possible to validate this using regex? For example: 1aa is valid 123 is not valid I tried using: ^[a-zA-Z]{1,5}$ but it doesn't work if there are any numerics in ...

32. Regex help needed for name validation.    coderanch.com

33. Validate ID through RegEx    coderanch.com

34. Validating the file path using regex    coderanch.com

Hi all, I am new to regex and need some help. I have a file path and file name in a String. This file path and file name are accessed from a Windows machine as well as Mac machine. So, when created via the Mac machine, file path and file name can have special characters like * @ $ ? etc., ...

35. Check validation of the Regex    java-forums.org

Hi Check like this.I have demonstrated with the small piece of code.Just it checks the text for "*".if it finds then it prints invalid else valid. Go thru the below link for better understanding. Pattern (Java 2 Platform SE v1.4.2)) import java.util.regex.*; class LogIn { public static void main(String args[]) { String input = "sun*com"; //Checks for the string which is ...

36. Regex for validation of an input file from file    java-forums.org

Why do people always try to do things with one big ugly moloch of a RE? Why not use the split( ... ) method instead? (read the String class API documenation). The split( ... ) method gives you an array of Strings, say s[], where s[0] is the first atom name s[1] and s[2] give you the second atom name and ...

37. Regex validation help    forums.oracle.com

find() looks for a match anywhere in your target string so will always return true if you have an alpha in it. Use matches() if you want the WHOLE string to be alpha characters. Since your regex allows both upper and lower case characters there is no need for the CASE-INSENSITIVE flag. Also, what makes you think you need the DOTALL ...

38. java input validation with regular expression    forums.oracle.com

39. Regular Expression validation    forums.oracle.com

Hi, I have one problem with regular expression. I just want to validate a field where it should accept only numbers with minimum 5 and maximum 9. i tried with this regular expression. string exp = " d{5,9}"; it works fine accepting only numbers with min 5 and max 9, but what happens here is it is accepting alphabets and special ...

41. Java validation with regular expression    forums.oracle.com

Hi I need to validate a string such that only numbers, alphabets, -, _, . is allowed and the below mentioned code works fine. if( ! l_name.matches("[A-Za-z0-9._-]+" ) ) { // do stuff when a valid name is found } But i need to modify the above regex such that it should also allow space in the name. Any idea how ...

42. Validate string in regular expression    forums.oracle.com

Hi I wanted to validate a name input in my project to check if it contains only characters or number and special characters like .(dot), -(hyphen) or _(underscore) I have formed this regular expression to check that: if(l_name.matches("[A-Za-z0-9._-]" ) ) I am not sure whether it is right..anyway it does not work. Can somebody please correct me what is going wrong ...

43. Regular expression for field validation    forums.oracle.com

Hi all, I am new to usage of regular expressions. I need to validate an input field :- user is allowed to enter values in the following way :- ex:- 1,3,7-10,15 - Here 7-10 means (7,8,9,10). - every character other than those used here are invalid (i.e., no characters or any special characters other than comma (,) and hiphen ). Only ...

44. problem with regular expression validation    forums.oracle.com

45. String validation without regular expressions    forums.oracle.com

46. Problem with regexp, validation of a string    forums.oracle.com

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.