This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Java in General and the fly likes Regex question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Regex question" Watch "Regex question" New topic
Author

Regex question

Max Power
Ranch Hand

Joined: May 10, 2004
Posts: 47
hi, i am trying to build a regex that matches this string:

something[\^]something or something\^something

i tried something like this: .*(\\[)?\\^(\\])?.* but thats not working....

any ideas?
thanks
Ray Stojonic
Ranch Hand

Joined: Aug 08, 2003
Posts: 326
this seems to do it:

output:
true
true
false
David Harkness
Ranch Hand

Joined: Aug 07, 2003
Posts: 1646
Originally posted by Ray Stojonic:
this seems to do it:
String regex = ".*\\[?\\\\\\^\\]?.*";
Note that this will also matchandIf that's not cool, tryI haven't tried it though, but it seems reasonable given Ray's test cases.
[ November 08, 2004: Message edited by: David Harkness ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Regex question