|
| |||||||||
| Tags: content, file, file system, java, regular expression, size |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| RegEx - verify content and size
Hello, I need to check a string, it must contain an email whose maximum length is limited, the basic RegExp is Code: ^ [a-zA-Z0-9 \ -] (1). [a-zA-Z0-9 \ -] (1) @ [a-zA-Z0-9 \. \ -] (1) . [az] (2,5) $ |
|
#2
| |||
| |||
| Re: RegEx - verify content and size
Hello, You can go out with the following regular expression. Code: ^(?=.{ 1.100) $) [a-zA-Z0-9 \ -] (1). [A-zA-Z0-9 \ -] (1) @ [a-zA-Z0-9 \. \ -] (1). [az] (2,5) $ |
|
#3
| |||
| |||
| Re: RegEx - verify content and size
Hi Thank you for your response. I can not verify the size directly because I'm working on a function that checks each line of a file from a dozen online. This function takes the input file and a table containing a RegExp line of the file. The funny thing is that each line contains several fields. The line by line audit file with the RegExp works perfectly and is very powerful, my only problem is managing the email field. |
|
#4
| |||
| |||
| Re: RegEx - verify content and size
Hello, This expression should be valid with the RE engine standard Java API. I suppose the engine jakarta does not bear the Lookaround. Which is the standard java RE engine are you using? If you know that then please post back. Because I do not think what you are doing will succeed. Currently I do not have a way round, but if I come to know one then i will post. |
|
#5
| |||
| |||
| Re: RegEx - verify content and size
Hello, Lookaround No, I do not think you can get away with a single regexp. Maybe you should look for another engine. On the site of the regex lib Jakarta there is a link to the Project ORO which is compatible with Perl 5 (it seems to me that Lookaround appeared in perl 5), but I do not know what it's worth really. Edition after verification, I confirmed with OROIt should work. If you need you can try this and test. |
|
#6
| |||
| |||
| Re: RegEx - verify content and size
Hey, Here is my code, please check it and if I am wrong somewhere, then please guide me. Code: Public class TestRegExp {
Public static void hand(String[] args) {
String str = "(?=[^;]{ 7.100);) [a-zA-Z0-9\\-_]{1,}\\. [a-zA-Z0-9\\-_] (1) @ [a-zA-Z0-9\\-_\\.]{1,}\\. [a-zA-Z] (2) ";;
String strTest = "31122001";
Perl5Compiler com = new Perl5Compiler();
Perl5Matcher mat = new Perl5Matcher();
Perl5Pattern p;
try {
p = (Perl5Pattern) com.compiles(str);
if(mat.games(strTest, p)) {
System.out.System.out.println("OK");
} else {
System.out.System.out.println("not OK");
}
} catch (MalformedPatternException e) {
/ / TODO Auto-generated catch block
e.printStackTrace();
}
}
} |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "RegEx - verify content and size" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Verify password and regex | Gunner 1 | Software Development | 5 | 17-02-2010 05:44 AM |
| Regex to verify email address | Aaliya Seth | Software Development | 5 | 17-02-2010 03:50 AM |
| Regex to verify data | Gunner 1 | Software Development | 5 | 16-02-2010 05:27 AM |
| Verify the content of the textbox with multiple buttons on Form | Gadhadhar | Software Development | 5 | 23-01-2010 02:19 PM |
| Increase and Decrease Web Browser's Content size In a Second! | FaMe FacToR | Tips & Tweaks | 2 | 06-02-2009 12:01 AM |