Kentico Tag output but not links - kentico

With help from Branded, i have tag working. At this point, we don't need tags to link, so i have tags being displayed like this (in an ascx transformation):
<p class='date'><%# IfEmpty(Eval("DocumentTags"),"",Eval("DocumentTags").ToString() + " | ") %><%# FormatDateTime(Eval("Date"),"MMM d, yyyy") %></p>
This works, but i get the tags wrapped in double quotes. I'm traying TrimEnd, or LastIndexOf, but just getting errors.

Use the method Replace() on the double quotes. Something like Eval<string>("DocumentTags").Replace("\"", "") should work.

Related

how to trim whitespace between strings in selenium xpath python

I want to find elements containing name and age.
But Name can contain whitespace like "Jo hn", So I want to remove whitespace between strings.
So I made code below, but SyntaxError. How can I do this?
driver.find_elements_by_xpath('//*[#id="Nlist"]/section/ul/li/a/span[contains(text().replace(" ", ""),"' + NAME + '") and contains(.,"' + AGE + '")]')
text().replace(" ", "") is Syntax Error. Is there any method?
I need to do this when find elements because speed.
Here is the sample html used to trim the space(s) with in name and used contains to match the partial text.
<!DOCTYPE html>
<html>
<body>
<span>s upputuri-100</span>
<span>s upp uturi-100</span>
</body>
</html>
You can use translate method to replace the white space(s) with the desired char/empty. Below the xpath to get the span that contains supputuri and 100.
//span[contains(translate(.,' ' ,''),'supputuri')][contains(.,'100')]

Twig RAW filter on literal string not working

{{ (vendorData.description) ? vendorData.description : "<em>No Description Entered</em>"|raw }}
When the value is not present I see:
<em>No Description Entered</em>
Printed literally on the screen in the web browser.
Raw should force the characters to be literal, not > < etc.
Why does this not work on a "created string" but if I do it on a string variable it works?
You need to place brackets around the whole statement like so:
{{ ((vendorData)
? vendorData
: "<em>No Description Entered</em>")|raw }}
Here is a working twigfiddle to show it working:
https://twigfiddle.com/fs2oc2
You can use twigfiddle to experiment with your code.
From feedback in comments section:
here is a twig example to show what you need: https://twigfiddle.com/hjyslr

VB6 Split String with < > Characters

I am trying to split something like this
When the Source is from a webpage and contains this value multiple times, but I don't think will split it because of the "<" character, any way around this?
SourceSplit = Split(Source, "<span class='BText' id='BText'>")
I tried using Chr(60) instead, didn't like that either, any ideas?
Thanks for any help
I would guess that the HTML uses double quotes for attribute values, not single. You need to escape the double quotes:
SourceSplit = Split(Source, "<span class=""BText"" id=""BText"">")

Replace numbers in a string

I Have some text file. theses texts contain a string like this(a part of text):
<abbr class="word p1"">dd</abbr>
<img src"D:\Images\1.png">
<abbr class="word p1">dd</abbr>
<img src"D:\ticket\t\1.png">
In each text file,(D:\Images\1.png) png name is different but it is always numbers(from 1 to 114)for example(1,2,3,10,...)
I want to replace this text D:\Images\[number].png with a specific text for expample:
string newtext=Replace("D:\Images\[number].png","Something");
How can i do this?
thanks.
Use a regular expression:
string newtext = Regex.Replace(text, #"(D:\\Images\\)\d+(.png)","$1Something$2");
It will replace the full match, including D:\Images\ and .png, so $1 and $2 puts back what's caught by the parentheses, so that Somthing only replaces the digits.
Use regular expressions that are represented mostly be the Regex class. See these links:
http://www.codeproject.com/Articles/93804/Using-Regular-Expressions-in-C-NET
http://msdn.microsoft.com/en-us/library/ms228595%28v=vs.80%29.aspx

Replace text inside div

I have a lot of html files that I want to add a rel="nofollow" to all the a href tags that are into a specific div.
I think c# code can do it. But how do I relate only partial code..?
Any suggestion? also I didnt realy know
Here is what I think:
Parse the HTML line by line
Look for " block start you would need to find the means look for "/div>".
Store all the content between "" into a string
check if "href=" is found and how many
Now parse this string again to search all "" and match with "href=" counter
#5 will give you an array of "href=" tag based lines
Now you can assume every "href=" tag must have ">" at the end of the "
At the last this is what you can do:
string s1 = " this is link ";
string s2 = s1.Insert(s1.IndexOf(">"), " rel=\"nofollow\"");

Resources