• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Finding exact match of one string in another..

 
Ashish Patel
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Balaji Loganathan
author and deputy
Bartender
Posts: 3150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
>>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>
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic