From: amwaterhouse Date: Wed, 12 Jan 2005 18:14:44 +0000 (+0000) Subject: regular expression added X-Git-Tag: Release_2_0~783 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=5b6d555458f48c4631883a8769fcc1dd5f578e34;p=jalview.git regular expression added --- diff --git a/src/jalview/gui/Finder.java b/src/jalview/gui/Finder.java index 909ba1f..e1a3082 100755 --- a/src/jalview/gui/Finder.java +++ b/src/jalview/gui/Finder.java @@ -6,7 +6,7 @@ import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; import java.util.*; - +import java.util.regex.*; public class Finder extends GFinder { @@ -112,15 +112,19 @@ public class Finder extends GFinder item = seq.getSequence(); + Pattern pattern = Pattern.compile(searchString); + Matcher matcher = pattern.matcher(item); + for(int r = resIndex; r-1) + + if( matcher.find( r ) ) { - resIndex = item.indexOf(searchString,r); + resIndex = matcher.start(); - searchResults.add( Integer.toString(seqIndex) ); + searchResults.add( Integer.toString( seqIndex) ); searchResults.add( Integer.toString( resIndex) ); - searchResults.add( Integer.toString( (resIndex+searchString.length()-1) ) ); + searchResults.add( Integer.toString( matcher.end()-1 ) ); if(!findAll) { // thats enough, break and display the result @@ -141,19 +145,10 @@ public class Finder extends GFinder if(searchResults.size()>0) { - allResults = new int[searchResults.size()]; for(int i=0; i