String Pattern Matching

Hi,

I am working on a project that needs to identify a particular String from another String, however, the location where the match will occur is unknown. For example, I would want to identify a line that includes operators such as "++" or "--".

if (Pattern.matches("++", lineSplit[j])){

....//other irrelevant codes here.

}

wherelineSplit[j] is an element from an already set String array.

I'm considering usingPattern.matches for this, but it shows me a compiling error:

java.util.regex.PatternSyntaxException: Dangling meta character '+' near index 0

++

^

I've tried usingsplit too, but it shows a similar error.

The last resort would be to use other pattern matching algorithm to search the entire document, but it would be MUCH, MUCH less efficient to code. Is there any way to solve this? or do I have to brace myself for the new RAM chip I'll be needing for this?

[1138 byte] By [Heloisec] at [2007-9-30 19:54:38]
# 1
http://java.sun.com/developer/technicalArticles/releases/1.4regex/may be this link will be of help for youand try this one: Pattern.matches("[+]{2}")
yahhont at 2007-7-7 0:41:41 > top of Java-index,Administration Tools,Sun Connection...
# 2

I think to find out whether the Specified string is present or not we can find out like this.

String str="this is ++ and --";

if(str.indexOf("++")==-1)

System.out.println("++ is present");

else

System.out.println("++ is not present");

Or if we want to find out the line number of that string , by parsing the entire lines of text line and using above code and incrementing line numbers we can achieve. hope so.

regards

glrao

glrao at 2007-7-7 0:41:41 > top of Java-index,Administration Tools,Sun Connection...