Deletion of a specific word in the repeater
source link: https://www.codesd.com/item/deletion-of-a-specific-word-in-the-repeater.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Deletion of a specific word in the repeater
I'm trying to remove a specified word/line from a string in a repeater and cut the length of the string
public static string CutTextLength(string text)
{
if (text.Length > 400)
{
text = text.Substring(0, 400) + "...";
Regex.Replace(text, "<br />", "");
}
return text;
}
<div class="JobContent"><%#CutTextLength(Eval("Text").ToString()) %></div>
When running this code i'm only reducing the length of the string but not removing all the <"br /"> tags in the string. Can anyone help me with my problem?
You should do:
text = Regex.Replace(text, "<""br /"">", "");
because Replace
doesn't alter text but returns a new string with the replacements.
Edit
On close reading your question I discovered you want to remove <"br /">
. The above, updated statement should do the job.
Related Articles
Deleting rows containing specific words in a text file to Ruby
Is there a way to classify an ID according to a specific word in the ID name?
Select specific words in the string that are not surrounded by quotation marks
Delete packages contain a specific word in the name
Deleting rows with specific words with VBA
Want a specific word from the list from a given string
Nginx matches a specific word in the location
Linux: extract a word after a specific word on the same line
How to color a specific word in the paragraph tag?
Display only the values containing specific words in the table
Allow only specific words in the URL by htaccess
href into a specific word of the channel using JavaScript and HTML5
How to highlight a specific word in the WebBrowser C # control
I need an elegant way to exclude specific words from the treatment
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK