I have to display "#" in the UITextview content and after to put some information.
I looked on the internet via google but I didn't find an explanation which make
me understand the good approach.
Can you help me with some extra advice ?
Thanks !
You can simply do it like this:
_textView.text=#"#Hi Hello"; result will be #Hi Hello
However if you want to use " in the text you need to append it to backslash \
_textView.text=#"#Hi \"Hello"; result will be #Hi "Hello
You can enter almost all special characters without any problem, but you need to take care for the double quotes:
_textView.text=#"#Hi \"Hello * ! # # $ % ^ & ( ) _ + - [ ] ; ' {} <> ,. / ? : \" ";
Related
I'm using the following ARRAYFORMULA to create an image path:
=ARRAYFORMULA(
if(row(A:A)=1,"#Icon",IF(
B:B="",,SUBSTITUTE(
"../../../../../../_Assets/Icons/"& LOWER(B:B&".png"), " ", "_")
)
)
)
What it does
Adding a path before the text and replaces all spaces with an underscore '_'. Here is an example:
Name
#icon
A Tit(l)e
../../../../../../_Assets/Icons/a_tit(l)e.png
Title - Subtitle
../../../../../../_Assets/Icons/title _-_subtitle.png
Title text/string - Subtitle
../../../../../../_Assets/Icons/title_text/string _-_subtitle.png
What I want it to do
If possible, I would like to achieve the following:
Avoiding/removing characters in the list below like the forward slash / with an underscore _ (see the last row in my example above)
It allready replaces all white spaces with an underscore _ which is good. But when it sees a whitespace followed by a - and another whitespace it will output _-_ but then I want only a -
So the current table above would output the following instead:
Name
#icon
A Tit(l)e
../../../../../../_Assets/Icons/a_tit(l)e.png
Title - Subtitle
../../../../../../_Assets/Icons/title-subtitle.png
Title text/string - Subtitle
../../../../../../_Assets/Icons/title_text_string-subtitle.png
List of characters to be avoided/replaced with an underscore _:
# pound
% percent
& ampersand
{ left curly bracket
} right curly bracket
\ back slash
< left angle bracket
> right angle bracket
* asterisk
? question mark
/ forward slash
blank spaces
$ dollar sign
! exclamation point
' single quotes
" double quotes
: colon
# at sign
+ plus sign
` backtick
| pipe
= equal sign
Any help/suggestion would be much appreciated!
Put list of avoided chars into column and use REGEXREPLACE:
=ARRAYFORMULA(if(row(A:A)=1,"#Icon",IF(A:A="",,"../../../../../../_Assets/Icons/"&LOWER(REGEXREPLACE(REGEXREPLACE(A:A," - ","-"),TEXTJOIN("|\",0,D2:D23),"_")) & ".png")))
try:
=ARRAYFORMULA({"#Icon",
IF(B2:B="",,SUBSTITUTE(SUBSTITUTE(
"../../../../../../_Assets/Icons/"&LOWER(B2:B&".png"), " ", "_"), "_-_", "-", 1))})
This is probably a rather trivial question for the Erlang experts - I'm trying to have my ejabberd server store offline messages (in a Riak db) which inherently do contain double quotes (") around various values, etc. I get a format error when I try to create a Riak database object from them, and testing of replacing the double quotes with an escape character (\") corrects the issue. The question is how can I do this replacement manually?
I tried the following code but somehow doesn't work.
(ejabberd#xxx-xx-xx-xxx)4> re:replace(""hello"", """, "\"", [{return, list}, global]).
* 1: syntax error before: hello
So essentially I'm trying to replace the embedded " around the hello word with \".
I don't know Erlang, but you probably need something like this:
"\"hello\"", "\"", "\\\""
You must escape both " and \ in replacement string.
The Erlang literal syntax for strings uses the "\" (backslash)
character as an escape code. You need to escape backslashes in literal
strings, both in your code and in the shell, with an additional
backslash, i.e.: "\".
Example:
Let's make an example. I use $ Erlang symbol which will be substituted with ascii integer of a character to show what is happening behind each string which basically is a list of integer.
Subject = [$"] ++ "hello" ++ [$"] = "\"hello\"".
Target = [$"] = "\"".
Replacement = [$\\, $\\, $"] = "\\\\\"".
Result = re:replace(Subject, Target, Replacement, [{return, list}, global]).
Now with getting the length of Subject and Result we can find the difference:
7 = length(Subject). %% => 7 characters: " h e l l o "
9 = length(Result). %% => 9 characters: \ " h e l l o \ "
I'm currently parsing what looks to be a proprietary file format from a third-party commercial application. They seem to use a funny character encoding system and I need some help determining what it is, assuming it's not a proprietary encoding system as well.
I don't have a whole lot of different characters to analyze from but here is what I have so far:
__b -> blank space
__f -> forward slash
So for example, "Hello World" become "Hello__bWorld".
Does anybody have any idea what this is?
If not do you know of a resource on the web that can help me? Maybe there is a tool out there than can help in identifying character encoding?
It seems to be a proprietary encoding used by Numara FootPrints. This list of mappings comes from the FootPrints User Group forum. There is also a Perl script for decoding it.
Code Character
__b (space)
__a ' (single quote)
__q " (double quote)
__t ` (backquote)
__m # (at-sign)
__d . (period)
__u - (hyphen-minus)
__s ;
__c :
__p )
__P (
__3 #
__4 $
__5 %
__6 ^
__7 &
__8 *
__0 ~ (tilde)
__f / (slash)
__F \ (backslash)
__Q ?
__e ]
__E [
__g >
__G <
__B !
__W {
__w }
__C =
__A +
__I | (vertical line)
__M , (comma)
__Ux_ Unicode character with value 'x'
I need to take/cut first 300 words or characters from a string.
That means, I need a limited number of characters from a string, from the beginning.
Something like truncating.
Is there a function to do this?
str = "many words here words words words ..."
first_500_words = str.split(" ").first(500).join(" ")
first_500_chars = str[0..500]
Depending on the size of your text and performance needs, one option is #text.split(/\s+/).slice(0,300).join(' ')
If you actually want to truncate on character level, which is advisable because different words differ in display length quite a bit, use:
def truncate_words(text, length = 300, end_string = ' …')
words = text.split()
words[0..(length-1)].join(' ') + (words.length > length ? end_string : '')
end
which I found here: http://snippets.dzone.com/posts/show/804
If you're using Rails, you can also use string.truncate but it does not take into account word boundries.
str = "this is really long string which I want to truncate..."
str.truncate 300, separator: " "
or if you prefer to youse brackets
str.truncate(300, separator: " ")
It's the most elegant solution of all above. As you mentioned in the topic, you use Rails so it will work. If you code in raw Ruby, you should write something like this:
str.split.first(300).join " "
The split method no need to take argument if you need to split the text by spaces.
I'd like to use convert_uudecode function, but encoded string contains a quotation mark ( " ) and also an apostrophe ( ' )
I can't just do it like this:
print convert_uudecode("M:'1T<#HO+V1N87=R;W0N;F%Z=V$N<&PO;&EC96YC97,O8F5S="UD96%L'0` ` ");
cos as you can see there is already a quotation mark.
I also cant do it this way:
print convert_uudecode('M:'1T<#HO+V1N87=R;W0N;F%Z=V$N<&PO;&EC96YC97,O8F5S="UD96%L'0` ` ');
becouse rendered string also contains an apostrophe.
Any help?
Regards,
David
Exchange each Apostrophe ' inside the string with '
and for each Quotation mark " you need to use "
An another alternative is to replace the " with \" and ' with \'
Visit this link below:
Hexadecimal value, Entity encoding etc
http://msdn.microsoft.com/en-us/library/aa226544%28v=sql.80%29.aspx