string

Getting Twitter characters count

怎甘沉沦 提交于 2021-02-19 06:17:07
问题 I have a program, it is an editor for Twitter tweets, it's counting the text to make it less than 280 character as twitter restriction. I use for that utf8 property like this: var str = "℞" let r = str.utf8.count The result = 3 This symbol (℞) and more like it takes only 2 character in twitter counter but the result in this code gave me 3, so i can't give the user the exact character count! How can I get the correct count: 2 回答1: Counting characters Tweet length is measured by the number of

sscanf usage on matrix of unknown size?

此生再无相见时 提交于 2021-02-19 05:26:16
问题 So, I have a file that contains a matrix of NxM size. For example: P2 3 3 1 1 0 0 0 1 0 0 0 1 The 'P2' is just an useless indicator, the first '3' indicates how many columns are and the second '3' indicates how many lines, '1' indicates the maximum value among the matrix's numbers. This matrix was stored in a data structure like this: typedef struct { int c; // columns int l; // lines unsigned char max; // max value unsigned char** data // variable to store matrix's numbers } Matrix; To store

gnuplot - convert a string variable to lowercase

牧云@^-^@ 提交于 2021-02-19 05:19:33
问题 How do you convert a string to lowercase in gnuplot? This is a gnuplot string handling question. Example:- I wish to check a user typed parameter in a gnuplot script.... if (tolower(ARG2) == "ohms") {..... so by accepting "ohms", "Ohms", or "OHMS". The preference is to not need to use an external "system" command so that the script is more portable. My current best solution is arg2 = system("awk 'BEGIN { print toupper(\"".ARG2."\") }'") and then test the new string variable "arg2", but awk

gnuplot - convert a string variable to lowercase

时光总嘲笑我的痴心妄想 提交于 2021-02-19 05:17:31
问题 How do you convert a string to lowercase in gnuplot? This is a gnuplot string handling question. Example:- I wish to check a user typed parameter in a gnuplot script.... if (tolower(ARG2) == "ohms") {..... so by accepting "ohms", "Ohms", or "OHMS". The preference is to not need to use an external "system" command so that the script is more portable. My current best solution is arg2 = system("awk 'BEGIN { print toupper(\"".ARG2."\") }'") and then test the new string variable "arg2", but awk

Storing and using strings of varying length (ADA)

蓝咒 提交于 2021-02-19 05:06:50
问题 Im working on a problem where I need to make a set of boxes according to an input number where each and every box has a unique name. I've managed to create the boxes but I've only managed to insert one name on all of them as my names are overwritten in the name collecting procedure. here is the code https://pastebin.com/FBMvvrn4 with Ada.Text_IO; use Ada.Text_IO; with Ada.Float_Text_IO; use Ada.Float_Text_IO; with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; procedure exercise is N : Integer

Split string by all spaces except those in parentheses

对着背影说爱祢 提交于 2021-02-19 03:59:20
问题 I'm trying to split text the following like on spaces: var line = "Text (what is)|what's a story|fable called|named|about {Search}|{Title}" but I want it to ignore the spaces within parentheses. This should produce an array with: var words = ["Text", "(what is)|what's", "a", "story|fable" "called|named|about", "{Search}|{Title}"]; I know this should involve some sort of regex with line.match(). Bonus points if the regex removes the parentheses. I know that word.replace() would get rid of them

Split string by all spaces except those in parentheses

▼魔方 西西 提交于 2021-02-19 03:59:04
问题 I'm trying to split text the following like on spaces: var line = "Text (what is)|what's a story|fable called|named|about {Search}|{Title}" but I want it to ignore the spaces within parentheses. This should produce an array with: var words = ["Text", "(what is)|what's", "a", "story|fable" "called|named|about", "{Search}|{Title}"]; I know this should involve some sort of regex with line.match(). Bonus points if the regex removes the parentheses. I know that word.replace() would get rid of them

Is it possible to extend a class by using a string as a module ? - Ruby 2.7.1

不打扰是莪最后的温柔 提交于 2021-02-19 03:54:05
问题 I am doing some tests with Ruby 2.7.1 on FreeBSD 12.1. I know how to extend a class with module with for instance this : class Myclass def mymethod extend Mymodule end end But is it possible to obtain the same result with something that looks like this : class Myclass def mymethod var = "Mymodule" extend var end end If I do this like that, I off-course obtain an error, since extend is pointing to a string and not a module. Here are some explanations - it would be useful in the following

Can a string with the word NULL in it ever be interpreted as a NULL value?

て烟熏妆下的殇ゞ 提交于 2021-02-19 03:44:09
问题 Looking for explanations for an error in a db insert, or update, I was told the problem is a customer name like: "BOB NULL-Creations" . What I have read about NULL doesn't allow me to accept that explanation so easily. However I have been wrong about other things before. Is it ever possible for the string 'NULL' to ever be interpreted as a NULL value in a situation where it is part of a string? A little more information The data is being ultimately viewed on an iPad so I am told the NULL

Why do I have to pass a callable to re.sub to make an uppercase string?

非 Y 不嫁゛ 提交于 2021-02-19 03:34:46
问题 Below is a somewhat contrived example that get's at my eventual question... I would like to use regex to uppercase the first character of a possessive noun. Let's say that I have a regular expression that (probably poorly) matches possessive nouns. ie... ### Regex explanation ### # 1. match a word break # 2. match a word-like character and capture in a group # 3. lookahead for some more characters + the substring "'s" >>> my_re = re.compile(r"\b(\w)(?=\w+'s)") >>> re.search(my_re, "bruce's