Thread: Regex pattern
View Single Post
  #4 (permalink)  
Old 12-11-2007, 11:58 AM
staykovmarin staykovmarin is offline
Senior Member
 
Join Date: Nov 2007
Location: Newport, WA
Posts: 141
staykovmarin is on a distinguished road
Sorry i missed your reply :\
This should work just fine:
Code:
Pattern p = Pattern.compile("^(\\w+[-]\\w+).html");
What that says is:
^ means the beggning of the line. it gets rid of problems like asd$#!%sd-tasd.html
\\w A word character: [a-zA-Z_0-9]
+ one or more character
() mean to take the entire input

Sorry about my previous reply, i wasnt quite awake .

small note: you dont need the \\ for -. You can have them, it wont hurt anything, but they are not required since - is not a special character.
Reply With Quote