jQuery in Action, 3rd edition
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
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

Finding exact match of one string in another..

Ashish Patel

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 :-
--- 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

Joined: Jul 13, 2001
Posts: 3150

Have you tried test?

<xsl:if test="'String_to_be_searched_Within'='String_to_be_searched_For'">

Spritle Software Blogs
Dirk Schreckmann

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..
It's not a secret anymore!