Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi,
Using 7.1.4
Does anyone know how i can make the following ignore casing?
@Html.Raw(result["copy"].Replace(searchTerm , "<strong>" + searchTerm + "</strong>").Truncate(200))
Thanks
p.s. @using Examine.LuceneEngine.SearchCriteria
@inherits Umbraco.Web.Macros.PartialViewMacroPage
Hi Kerri,
To ignore case you should be able to use the ToLower() method. What if you do something like this:
@Html.Raw(result["copy"].Replace(searchTerm.ToLower() ,"<strong>"+ searchTerm.ToLower() +"</strong>").Truncate(200))
Hope this helps,
/Dennis
Hi Dennis,
Thanks but it didn't work :( If i lower all the copy like below the replace works but obviously it lower cases all the text which I don't want
@Html.Raw(result["copy"].ToLower().Replace(searchTerm ,"<strong>"+ searchTerm +"</strong>").Truncate(200))
I didn't know if there was some way of using Regex.Replace, I've tried the below but no luck
@Html.Raw(result["copy"].Regex.Replace(searchTerm , "<strong>"+ searchTerm +"</strong>", RegexOptions.IgnoreCase).Truncate(200))
I think that you are on the right track with this one:
@Html.Raw(result["copy"].Regex.Replace(searchTerm ,"<strong>"+ searchTerm +"</strong>",RegexOptions.IgnoreCase).Truncate(200))
Could the reason why your code doesn't work, is because that you don't have an regex. Or did the serachTerm contains a regex.
Maybe this post can help you to get the syntax right, I hope so
http://our.umbraco.org/forum/developers/razor/28100-regular-expression-help
Thanks Dennis,
I don't know anything about Regex so i'll have to do some research!
The code just gives me: Error loading Partial View script (file: ~/Views/MacroPartials/SearchResults.cshtml)
Thanks again anyway
Kerri
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
incasesensitive replace in search results
Hi,
Using 7.1.4
Does anyone know how i can make the following ignore casing?
Thanks
p.s. @using Examine.LuceneEngine.SearchCriteria
@inherits Umbraco.Web.Macros.PartialViewMacroPage
Hi Kerri,
To ignore case you should be able to use the ToLower() method. What if you do something like this:
Hope this helps,
/Dennis
Hi Dennis,
Thanks but it didn't work :( If i lower all the copy like below the replace works but obviously it lower cases all the text which I don't want
@Html.Raw(result["copy"].ToLower().Replace(searchTerm ,"<strong>"+ searchTerm +"</strong>").Truncate(200))
I didn't know if there was some way of using Regex.Replace, I've tried the below but no luck
Thanks
Hi Kerri,
I think that you are on the right track with this one:
Could the reason why your code doesn't work, is because that you don't have an regex. Or did the serachTerm contains a regex.
Maybe this post can help you to get the syntax right, I hope so
http://our.umbraco.org/forum/developers/razor/28100-regular-expression-help
/Dennis
Thanks Dennis,
I don't know anything about Regex so i'll have to do some research!
The code just gives me: Error loading Partial View script (file: ~/Views/MacroPartials/SearchResults.cshtml)
Thanks again anyway
Kerri
is working on a reply...