Results 1 to 11 of 11
Thread: A Simple Regular Expression...
 01302012, 01:02 AM #1`
 Join Date
 Dec 2011
 Posts
 7
 Rep Power
 0
A Simple Regular Expression...
Hey, im new to RegEx. Lets suppose I have the following:
import java.util.regex.*;
public class RegexValidation {
public static void main (String[]args){
String RE1="\\+?[09]* ?(\\(0\\))?[09. ]{7,}";
String RE2="\\w[.\\w]*@\\w[\\w]*\\.\\w[.\\w]*";
String RE3="\\w[,. \\w]*";
String RE4="[AZ]{1,2}[09R][09AZ]? [09][AZ[CIKMOV]]{2}";
//code here...?
}
}
I need to validate these contact details using the regular expressions int he String's. The question is:
contentmanager@bradford.ac.uk
University of Bradford
Bradford, West Yorkshire
BD7 1DP
UK
+44 (0)1274 232323
(i) Find the number of matches for each of the regular expressions RE14, taking as inputstrings whole lines in the contact details given above.
(ii) Suggest how to rename the regular expressions RE14 to indicate which details they validate, e.g. rename RE3 to EMAIL_RE (check!).
If you could please help me out, would be kind of you. Thank you :)

Re: A Simple Regular Expression...
Help you out  how? You haven't told us where exactly you're stuck.
 01302012, 01:20 AM #3`
 Join Date
 Dec 2011
 Posts
 7
 Rep Power
 0
Re: A Simple Regular Expression...
on the first question of writing code:
(i) Find the number of matches for each of the regular expressions RE14, taking as inputstrings whole lines in the contact details given above.
Firstly, what is "RE14" ?
 01302012, 01:23 AM #4Senior Member
 Join Date
 Jan 2012
 Posts
 210
 Rep Power
 5
Re: A Simple Regular Expression...
Reference variables of String type.

Re: A Simple Regular Expression...

Re: A Simple Regular Expression...
 01302012, 01:31 AM #7`
 Join Date
 Dec 2011
 Posts
 7
 Rep Power
 0
Re: A Simple Regular Expression...
ok I misread "each" lol, and how do I now actually find the number of matches for each of these regular expressions taken as input strings whole lines in the following contacts:
contentmanager@bradford.ac.uk
University of Bradford
Bradford, West Yorkshire
BD7 1DP
UK
+44 (0)1274 232323
and also how would I rename the regular expressions RE14 to indicate which details they validate please?

Re: A Simple Regular Expression...
The Java regular expressions tutorials shows you how to use a while loop to iterate through and "find()" each match.
and also how would I rename the regular expressions RE14 to indicate which details they validate please?
 01302012, 01:37 AM #9`
 Join Date
 Dec 2011
 Posts
 7
 Rep Power
 0
Re: A Simple Regular Expression...
Thank you very much!
 01302012, 01:43 AM #10Senior Member
 Join Date
 Jan 2012
 Posts
 210
 Rep Power
 5

Similar Threads

regular expression
By ehsansad in forum New To JavaReplies: 8Last Post: 03182011, 03:23 PM 
Help with regular expression
By mr.ab18 in forum New To JavaReplies: 2Last Post: 08062010, 10:01 PM 
regular expression
By prof.deedee in forum JDBCReplies: 3Last Post: 02192010, 12:15 PM 
regular expression
By QkrspCmptPop in forum Advanced JavaReplies: 8Last Post: 01202010, 04:55 AM 
regular expression
By ras_pari in forum Advanced JavaReplies: 27Last Post: 10072009, 12:25 PM
Bookmarks