wood burning stoves*
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
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 ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Regex question
 
Similar Threads
How to validate french chars? (Base on external file name)
treating variable as regex
regex - only allow numbers & one decimal
Regular Expression Question
Regex