Index: /FCKeditor/trunk/_whatsnew.html
===================================================================
--- /FCKeditor/trunk/_whatsnew.html	(revision 1540)
+++ /FCKeditor/trunk/_whatsnew.html	(revision 1541)
@@ -97,4 +97,7 @@
 			"Find what" fields in the Find and Replace dialog would now activate the find and replace 
 			buttons.</li>
+		<li>[<a target="_blank" href="http://dev.fckeditor.net/ticket/1828">#1828</a>] The Find/Replace dialog
+			will no longer display wrong starting positions for the match when there are multiple and identical
+	       		characters preceding the character at the real starting point of the match.</li>
 	</ul>
 	<p>
Index: /FCKeditor/trunk/editor/dialog/fck_replace.html
===================================================================
--- /FCKeditor/trunk/editor/dialog/fck_replace.html	(revision 1540)
+++ /FCKeditor/trunk/editor/dialog/fck_replace.html	(revision 1541)
@@ -98,8 +98,8 @@
 function btnStat()
 {
-	document.getElementById('btnReplace').disabled =
-		document.getElementById('btnReplaceAll').disabled =
-			document.getElementById('btnFind').disabled =
-				( document.getElementById(idMap["FindText"]).value.length == 0 ) ;
+	GetE('btnReplace').disabled =
+		GetE('btnReplaceAll').disabled =
+			GetE('btnFind').disabled =
+				( GetE(idMap["FindText"]).value.length == 0 ) ;
 }
 
@@ -111,20 +111,20 @@
 function GetSearchString()
 {
-	return document.getElementById(idMap['FindText']).value ;
+	return GetE(idMap['FindText']).value ;
 }
 
 function GetReplaceString()
 {
-	return document.getElementById("txtReplace").value ;
+	return GetE("txtReplace").value ;
 }
 
 function GetCheckCase()
 {
-	return !! ( document.getElementById(idMap['CheckCase']).checked ) ;
+	return !! ( GetE(idMap['CheckCase']).checked ) ;
 }
 
 function GetMatchWord()
 {
-	return !! ( document.getElementById(idMap['CheckWord']).checked ) ;
+	return !! ( GetE(idMap['CheckWord']).checked ) ;
 }
 
@@ -227,6 +227,7 @@
 // Knuth-Morris-Pratt Algorithm for stream input
 KMP_NOMATCH = 0 ;
-KMP_ADVANCED = 1 ;
-KMP_MATCHED = 2 ;
+KMP_STARTED = 1 ;
+KMP_ADVANCED = 2 ;
+KMP_MATCHED = 3 ;
 function KmpMatch( pattern, ignoreCase )
 {
@@ -263,5 +264,5 @@
 					return KMP_MATCHED;
 				}
-				return KMP_ADVANCED;
+				return this._State > 1 ? KMP_ADVANCED : KMP_STARTED ;
 			}
 			else if ( this._State == 0 )
@@ -307,16 +308,24 @@
 				matchState = matcher.FeedCharacter(data) ;
 
+				// No possible match of any useful substring in the pattern for the currently scanned character.
+				// So delete any positional information.
 				if ( matchState == KMP_NOMATCH )
 					matchBookmark = null ;
-				else if ( matchState == KMP_ADVANCED && matchBookmark == null )
+				// The currently scanned character is a possible start, so mark down the starting position.
+				else if ( matchState == KMP_STARTED )
 					matchBookmark = { Start : cursor.concat( [] ) } ;
+				// Found a complete match! Mark down the ending position as well.
 				else if ( matchState == KMP_MATCHED )
 				{
+					// It is possible to get a KMP_MATCHED without KMP_STARTED when the match pattern is only 1 character.
+					// So need to check and mark down the starting position as well.
 					if ( matchBookmark == null )
 						matchBookmark = { Start : cursor.concat( [] ) } ;
+
 					matchBookmark.End = cursor.concat( [] ) ;
 					matchBookmark.End[ matchBookmark.End.length - 1 ]++;
 
 					// Wait, do we have to match a whole word?
+					// If yes, carry out additional checks on what we've got.
 					if ( GetMatchWord() )
 					{
