File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes Finding exact match of one string in another.. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Finding exact match of one string in another.." Watch "Finding exact match of one string in another.." New topic
Author

Finding exact match of one string in another..

Ashish Patel
Greenhorn

Joined: Jan 30, 2004
Posts: 20
Hi all,

I would like to find the exact match of one string in another.
Currently i have used XPATH's contains() function to do this task, but the problem is it also returns true if it is not an exact match.


Syntax of contains() is :-
contains("'String_to_be_searched_Within','String_to_be_searched_For'")
--- Return value = true/false

See the e.g. :- If I want the string say 'ash' to be searched in a string 'Hello ashish .How r u?' , the contains() will return "true" bcoz. it finds "ashish" in the string which is not the exact match for "ash" which i have searched for.

So please give me an insight on how to solve this.


Thanks ,<br />Ashish
Balaji Loganathan
author and deputy
Bartender

Joined: Jul 13, 2001
Posts: 3150
>>contains("'String_to_be_searched_Within','String_to_be_searched_For'")

Have you tried test?

like
<xsl:if test="'String_to_be_searched_Within'='String_to_be_searched_For'">
True
</xsl:if>


Spritle Software Blogs
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Ashish P,

Welcome to JavaRanch!

We ain't got many rules 'round these parts, but we do got one. Please change your display name to comply with The JavaRanch Naming Policy.

We request something more than a single letter for the displayed last name.

Thanks Pardner! Hope to see you 'round the Ranch!


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Finding exact match of one string in another..