aspose file tools*
The moose likes Java in General and the fly likes Regular expression Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Regular expression" Watch "Regular expression" New topic
Author

Regular expression

Marilyn Monickam
Ranch Hand

Joined: Jun 05, 2001
Posts: 66
Hi
Using the javax.util regex package' Pattern matcher is it possible to write a Pattern to check if a string does not contain two or more consecutive hyphens or spaces
Thanks
Marilyn
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
Yeah - but it seems much easier to check if it does contain two consecutive hyphens or spaces, and interpret the result of find() accordingly.


"I'm not back." - Bill Harding, Twister
Marilyn Monickam
Ranch Hand

Joined: Jun 05, 2001
Posts: 66
Thanks Jim
Is there a method available that can return the pattern if I give a string?

Marilyn
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
Um, in one sense, that's what Pattern.compile() does - creates Pattern object based on an input string which represents that pattern. But I don't know if that's what you mean. If you mean, is there a method that will tell me to use " |--" in this situation, then no, not really. You have to read the documentation for the java.util.regex.Pattern class. And/or spend time with a good book like O'Reilly's Mastering Regular Expressions. Or just practice a lot.
Marilyn Monickam
Ranch Hand

Joined: Jun 05, 2001
Posts: 66
Its the second thing I wanted to know "if there is a method that will tell me to use " |--" in this situation ". Will have to try a lot of combinations now :-)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Regular expression