This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Java in General and the fly likes Regex question Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply 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://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Regex question
 
Similar Threads
Regex
Regular Expression Question
treating variable as regex
regex - only allow numbers & one decimal
How to validate french chars? (Base on external file name)