i want to call some substring text that i add in to virable
<xsl:variable name="substringbreakText">
<xsl:call-template name="insertBreaks">
<xsl:with-param name="subject" select="substring(PublicProfile/AboutMe,1,550)"/>
</xsl:call-template>
</xsl:variable>
and like go backwords on this text until i get white space or break.
so my point is to return string less then 550 chars but keep it look complate words
exmple:
thats my 550 chars:
"The image you see purports to depict Graham Bverly, Emeritus Professor of Academic Development in the Research Support Unit at Anglia ucla University, UK. He inquires into, and runs workshops on, writing for postgraduates and fellow academics.
But what messages does this portrait suggest to the reader? That Badley poses as an erudite thinker? That he seeks the light of truth? That he leans to the left? That he is, possibly, amused by such pretension? That he is sceptical? Perhaps. For ‘As a man is, so he sees’ (William Bleer).
Eme"
i want to cut the white space and "Eme" or cut the \r\n or in this string.
<xsl:value-of select="substring(#Description, 1, 500 + string-length(substring-before(substring(#Description, 501),' ')))" />
this could be changed to match a full stop or whatever to suit your needs :)
If you're in XSLT 1.0, finding the last space before the 550th character will involve recursion. Write a template which given a string:
(a) tests the last character of the string (using substring(s, string-length(s), 1))
(b) if it's a space, returns the string
(c) otherwise, calls itself passing substring(s, 1, string-length(s)-1) as the argument.
Pass this template substring(in, 1, 500) and it will return a string which ends with the last space in the supplied input.
Related
I want to split a string based on the lines, meaning seperating contents on seperate lines.
Example -
Hello I
am
Bill Gates
Final Array should be ["Hello I","am","Bill Gates"]
I tried using split function and passing '\n' but it ain't working.
<#assign finalValue = body?split('\n') />
I am not getting the desired result in this case. Can you please help me out with this?
For more details, read below -
I am trying to fetch country from an address. Country is always on the last line of address, so I am trying to SPLIT the address based on lines, thus fetching last line which is the desired output.
Example -
ABC, Industries Ltd.,
XYZ Street,
United States.
So here, I am using split function as address?split("\n") but it ain't working.
So, I tried splitting using Developers Console and it worked fine there. Used split() function.
Upon fetching the address value though, I am getting it as -
ABC, Industries Ltd., \n XYZ Street, \nUnited States.
Hence, thought of splitting using \n but it ain't working!
The usual problem is that there are 3 kind of line-breaks in use: \r\n (Windows and some Web protocols), \n (everything else), and very rarely \r (old Mac). The split that works with all is ?split(r'\R', 'r'). Note that the R is capital in \R. That's a regular expression construct, supported since Java 8.
Likely doesn't help the OP, but might help someone else from the frustration of trying to split on line break for an advanced PDF in NetSuite using Freemarker!
You need to use <br />
${var?split(r"<br />", "r")}
I have a calculation which will remove a blank space and replace with a full stop. This is correct for 90% of my cases. However, sometimes two blanks will appear in my value. For the second space I want to delete it. Is this possible?
I think it may be possible using a code stage, but I am not sure what the code would be.
My current calculation is Replace([Item Data.Name], " ", ".")
Example data John B Smith I want the result to be John.BSmith
For anything that'd like to do with the strings, there is a really powerful tool called Regular Expressions (regex). I encourage you to play with it, because it's a really powerful tool in the hands of RPA developer.
To replace the second space in any string with a "." you can use the following action.
Object: Utility - Strings
Action: Regex - Find and Replace
Input:
Regex Pattern: "(?<= .*) "
Text: "John B Smith"
Replacement: "."
The above action is not a standard Blueprism one, so it has to be added to your VBO. The action looks as follows:
The VB.net code for that action is as follows:
Dim R as New Regex(Regex_Pattern, RegexOptions.SingleLine)
Dim M as Match = R.Match(Text)
replacement_result = R.Replace(Text,Regex_Pattern,replacement_string)
There might be a need for some additional assemblies, so please see below a printscreen of references and namespaces used in my object:
I resolved this issue by using the Utility - Strings object and the split text action. I split my name by space. This outputted a collection which I was then able to loop through and add a full stop after the fist instance but then trim the other instances.
Please see screenshot
I think the simplest solution would be
Replace(Replace(Text," "," ")" ","."))
if you know that it will give one or two spaces
First replace the two white spaces to single and then again single white space to dot(.)
I have a cell in Excel that is pasted from outlook. When I read it in vba, there is some spaces on it and I need to remove.
It took me some hours to find the solution to remove it.
I tried:
Replace(string_value," ","") and did not remove the spaces
Application.find(" ", string_value) and returned error
Application.trim(string_value) and did not remove the spaces
...
My solution:
string_value = Replace(Str(string_value), " ", "")
Does anyone knows why?
Outlook emails can be written in two modes:
1) Plain text;
2) HTML (for allowing colors, layouts etc.)
You probably are into the second case, because a table cannot be inserted in plain text mode, and when you get the value of the variable string_value you get it in full HTML string.
What happens in fact is that Outlook converts your body in HTML to allow it being viewed from any mail server (HTML is the international web language, read by any browser uniformally, or almost). Which means, the character space will not any longer be " ", but rather its HTML equivalent, i.e.   (or something else, I don't know if there's a breakline or not, I'm not a real expert of HTML).
Hence, when you use one of the three methods above, none of them is able to find the "visual space", or better the string character " ". However, when you use the function Str(), the HTML string will be re-converted to VBA Language (i.e.   or equivalent will be converted in " " and your approach will hence work.
That is because the statement:
string_value = Replace(Str(string_value), " ", "")
does several things. Usually str() takes a Long argument. Becuase you are giving it a String, VBA (in the background) converts the string to a Long. In doing this it discards any junk characters (non-digits) like CHR(160).Str() pads the result with a blank, which Replace() removes !
Str Function on MSDN
Use:
Replace(string_value,CHAR(160),"")
Total newb to Prolog. This one is frustrating me a bit. My 'solution' below is me trying to make Prolog procedural...
This will remove spaces or insert a space after a comma if needed, that is, until a period is encountered:
squish:-get0(C),put(C),rest(C).
rest(46):-!.
rest(32):-get(C),put(C),rest(C).
rest(44):-put(32), get(C), put(C), rest(C).
rest(Letter):-squish.
GOAL: I'm wondering how to remove any whitespace BEFORE the comma as well.
The following works, but it is so wrong on so many levels, especially the 'exit'!
squish:-
get0(C),
get0(D),
iteratesquish(C,D).
iteratesquish(C,D):-
squishing(C,D),
get0(E),
iteratesquish(D,E).
squishing(46,X):-put(46),write('end.'),!,exit.
squishing(32,32):-!.
squishing(32,44):-!.
squishing(32,X):-put(32),!.
squishing(44,32):-put(44),!.
squishing(44,44):-put(44), put(32),!.
squishing(44,46):-put(44), put(32),!.
squishing(44,X):-put(44), put(32),!.
squishing(X,32):-put(X),!.
squishing(X,44):-put(X),!.
squishing(X,46):-put(X),!.
squishing(X,Y):-put(X),!.
Since you are describing lists (in this case: of character codes), consider using DCG notation. For example, to let any comma be followed by a single whitespace, consider using code similar to:
squish([]) --> [].
squish([(0',),(0' )|Rest]) --> [0',], spaces, !, squish(Rest).
squish([L|Ls]) --> [L], squish(Ls).
spaces --> [0' ], spaces.
spaces --> [].
Example query:
?- phrase(squish(Ls), "a, b,c"), format("~s", [Ls]).
a, b, c
So, first focus on a clear declarative description of the relation between character sequences and the desired "clean" string. You can then use SWI-Prolog's library(pio) to read from files via these grammar rules. To remove all spaces preceding commas, you only have to add a single rule to the DCG above (to squish//1), which I leave as exercise to you. A corner case of course is if a comma is followed by another comma, in which case the requirements are contradictory :-)
How to obtain document library name from the URL cqwp. For example,
http:///sites/site1/DocLib/Forms/AllItems.aspx
I know there is substring function with xsl
<xsl:param name="DocLibName">
select=substring(url) or whatever the code should be
</xsl:param>
The following code will give you the name of your document library from the URL you posted (or from any view in your document library)
String pattern = ".*/(?<listStaticName>.+)/[^\\.]+\\.aspx";
Regex regex = new Regex(pattern);
MatchCollection matches = regex.Matches(DefaultViewUrl);
String listStaticName = matches[0].Groups["listStaticName"].ToString();
You can use the method described in this article to call .NET code from XSL
Using the standard substring(string, int, int) function won't get you very far because I expect that the length of the document library name is unknown.
However, there are two functions that you can use in concert, substring-after(string, string) and substring-before(string, string). As long as your site names aren't "Forms", you can retrieve a partial string using substring-before([URL], "/Forms"). For the rest... it'll still be troublesome if you don't have immediate access to the site's name, but even removing that option it's still much easier than complex calculations in URL length. You'd basically have to continually perform substring-after([string], "/") until you pop off the last slash.
Some good Links.
http://msdn.microsoft.com/en-us/library/dd583143(office.11).aspx
Add these two line
<xsl:variable name="DocLibName" select="substring-before(substring-after($PageUrl, '/Forms/'), '/')" />
<xsl:param name="PageUrl"/>
set VIEWFLAG=1 (it should be in the properties windows)
Find this line and modify if you want Filter the webpart list
<xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row" />
Change it to following
<xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row[(#CustomerNo=$DocLibName)]"/>
You can use this to display
<xsl:value-of select="$DocLibName"> <br/>
<xsl:value-of select="$PageUrl"/><br/>