XPages - format data in a computed field - xpages

In my XPage, I have a computed field which displays several lines of text. I would like to display the field contents so that each sentence displays on a new line i.e. format the output so that a newline character is added to each sentence. How can I do this?

If you set property escape to "false" in computed field then you can get newlines with <br />. Assuming, you mean as a sentence a string ending with a period then you can use replace() to put the <br /> into your text:
<xp:text
escape="false"
id="computedField1">
<xp:this.value><![CDATA[#{javascript:
yourValue.replace(". ", ".<br />")}]]></xp:this.value>
</xp:text>
This is of course a very simple version. You'd get a newline if somewhere in the middle of a sentence is a period and you wouldn't get a newline if sentence ends with an exclamation or question mark. You should use a more sophisticated regular expression as parameters for replace() like suggested here.

Related

How can I add text strings to some fields based on finding a text string found in a portion of another field

How can I add text strings to a specific field in a record based on the contents of another field in that record?
One field in each record potentially contains four pieces of data I need to search for with text strings, and if present, I need to add corresponding text strings to another field, with | between multiple strings.
An example field might have content like this:
Some sentence that precedes the info:
This String
That String
*another sentence that precedes other info
A third string
And a fourth string
I'd need to search for "This String" "That String" "third string" and "fourth string", and in fields that had all four, add a string in the other field that read "this|that|third|fourth"
In a field that only had "This String" and "fourth string", the added field data would need to be "this|fourth"
I figured it out. I was overthinking and trying to do it backwards.
I exported a CSV of just the reference column, used a text editor to find and replace the strings I needed to remove and then replace the returns with the stovepipes. Hope this helps someone else. :)

Vim search and replace to amend a string with common structure but varying words

I'm fairly new to Vim and I haven't been able to find on this site how to search and replace with a varying part of a string. I need to apply a global edit to all times "SetTag("...")" appears with ... being any word. My edit is to add one more word after the second quotation mark. example: SetTag("err" + __LINE__ with the bolded part being what I need to add. Can anyone let me know how this is possible with a vim search command? Thanks!
nb: I assume "word" is any sequence of characters other than a doublequote character. Modify as needed.
:%s/SetTag("\([^"]*\)")/SetTag("\1" + __LINE__)/
the escaped parentheses grab the sub-match; the \1 in the replacement string is replaced by that sub-match.

search/replace contains ‘x’ and does not contain ‘y'

Does anyone know a way (regex search or plugin or anything other mac tools) i could search for a string i want to replace but only if another string is not on the same line.
This is Html code and i would like to search all files in a project that contain string <button and change it to <button type="button" as long as it doesn't contain the string type on the same line?
Currently using either sublime and atom but couldn't figure out how.
This can be done with a regex search and replace in Sublime, using a negative lookahead. Select Find → Replace… and in the Find What: box enter
(<button)(?!.*?type)
and in the Replace With: box enter
<button type="button"
Make sure the Regular Expression button is selected on the far left at the top.
Here is a demo. Basically, the first group (delineated by parentheses ( )) finds the opening part of the tag - simple enough. The second group (?!.*?type) is a negative lookahead ?! that searches for any character . repeated zero or more times and giving back reluctantly *? followed by the word type. The first group will match only if the second group does not match.

Pass new line to description field in ics export from sharepoint

I am exporting an ics file from a sharepoint list item using the following format:
http://sharepoint/site/_vti_bin/owssvr.dll?CS=109&Cmd=Display&List=[List GUID]&CacheControl=1&ID=[Item ID]&Using=event.ics
I have a column in my list called description, this gets passed to the generated ics file in the correct place but any \n's seem to get escaped to this \\n which displays as text in the calendar appointment.
I have tried many different options but cannot seem to get this working.
\n gets replaced with \\n
\134n gets replaced with \\n
\\n generates correctly but does not work
\012 seems to break the ics file unless it is followed by a whitespace character, but then it gets unfolded and ignored.
I refuse to believe that this is impossible. Any help will be appreciated and any solution will save me days of frustration.
I do not know how the original data is stored but icalendar spec (RFC5545) specs:
The "TEXT" property values may also contain special characters
that are used to signify delimiters, such as a COMMA character for
lists of values or a SEMICOLON character for structured values.
In order to support the inclusion of these special characters in
"TEXT" property values, they MUST be escaped with a BACKSLASH
character. A BACKSLASH character in a "TEXT" property value MUST
be escaped with another BACKSLASH character. A COMMA character in
a "TEXT" property value MUST be escaped with a BACKSLASH
character. A SEMICOLON character in a "TEXT" property value MUST
be escaped with a BACKSLASH character. However, a COLON character
in a "TEXT" property value SHALL NOT be escaped with a BACKSLASH
character.
Example: A multiple line value of:
Project XYZ Final Review
Conference Room - 3B
Come Prepared.
would be represented as:
Project XYZ Final Review\nConference Room - 3B\nCome Prepared.
So for your export to work you should leave \n as is, replace CRLF by \n and also hope your user has a standard compliant calendar tool.

Splitting a full name field into first and last name

I have a form with a full-name text field and I would like to break the string into a first and last name strings... I'm handling the form in Coldufusion.
What is the most reliable way to achieve this? I'm assuming JavaScript is not an option since, in its absence, the form would generate an error. Any examples would be great.
Thanks
Found a better solution
<cfset fullName = "foo bar">
<cfset firstName = listFirst(fullName, " ")>
<cfset lastName = listRest(fullName, " ")>
If you just want to split on the first space, you can use the list functions. For example, you could get the first word by using
<cfset first = listfirst(fullname, " ")>
List functions all take an optional parameter, delimiters, which lets you specify how the list is delimited. So, in this case, your list is space-delimited.
Remember that not all names are two words. People use middle names, constructs like "De Marco" and "Van DeGraff" and so forth, or multiple first names like "Lisa Ann". But this will get you a good approximation.
In coldfusion, after it is submitted, I would split it on a space character.
You can use GetToken(fullname,1) and getToken(fullName,2)

Resources